VB5 Express - Text Box Table

Associate
Joined
2 Nov 2008
Posts
790
I'm trying to work out how I can get a series of results (variables) into a textbox in a table format. I've looked around the internet for guides and stuff but I can't find any explaining how to do this.
This is the sort of thing im looking for, but displayed in a text box

x 1 2 3
1 1 2 3
2 2 4 6
3 3 6 9

I don't want/need lines around the text, just so that I can display more than one result in a text box in a fairly neat layout.

How would I go about doing this?
Thanks :)
 
Why are you using a text box to display formatted text?

Anyway.

textbox1.TextMode = MultiLine
textbox1.text = "x " & var1 & " " & var2 & " " & var3 & vbcrlf & var1 & " " & var1 & " " & var2 & " " & var3 & vbcrlf

although you should really use Environment.NewLine() instead of vbcrlf

Simon
 
Last edited:
Wouldn't it be better to make each number a button if you're re-making minesweeper? ;)

Looks like it's displaying times tables rather than minesweeper ;)

That being the case I would suggest simply outputting the formatted result onto the form (or whichever container control is being used) to give better results that using a textbox as SimonC has mentioned.

Also, I assume the OP means VB2005 Express?
 
Can't be mine sweeper it would have to be:

x 1 2 x
1 1 2 x
2 2 3 2
x x 2 x

:D



Did VB5 ever have an express version?

VB 2005 Express -.-' I'm using it for a uni course because it's free. :D

thanks for the help....



and i was using the times tables as an example :S
 
Ok I have a new question and I thought i'd add it on to this because it's kind of linked.

In the same way that SimonCHere has used vbCrLf is there anything i can do to make it tab across?


Also how do I round a double up?
Thanks
 
vbTab
:D

system.math.round()

or

you can use Ceiling

MessageBox.Show(Math.Ceiling(4.1)) => 5
MessageBox.Show(Math.Ceiling(4)) => 4

be aware that ceiling will round up even in negative numbers:

ceiling(-4.1) = -4
ceiling(-5) = -5
 
Last edited:
Back
Top Bottom