numbers

  • Thread starter Thread starter freddy
  • Start date Start date
F

freddy

how can I display a set of numbers like this:
1 2 3 4 5 6 ...
instead of this
1
2
3
4
5
....
 
Freddy,
I hope this is not a homework question! ;-)
For i As Integer = 1 to 50
Console.WriteLine(i)
Next i
For i As Integer = 1 to 50
Console.Write(i)
Console.Write(" "c)
Next i
Console.WriteLine()

Notice in the first one I used WriteLine to cause each item to appear on a
line by itself, where as in the second one I only used Write inside the
loop, and a WriteLine outside to loop to get a single line of output. (of
course the second one will wrap by itself once the line gets past 25
characters ;-))

Hope this helps
Jay
 
I just want to understand the code. I think I can use
jagged array,the problem is evertime I do a search it
comes up with c# not vb.net.
 
Freddy,
I just want to understand the code.
Understand what code, you have not shown any code, you asked how to
"display" something...
I think I can use
jagged array,the problem is evertime I do a search it
comes up with c# not vb.net.
Now up until this message you made no mention of an array. My code does not
involve arrays!

What is it you want to do, do you want to print numbers on the console as I
have shown? Or do you have an array question?

Do you want an array with a single column of 50 values?

Dim x(49) As Integer ' remember its high bound, not length

Do you want an array with a single row of 50 values?

Dim x(0,49) As Integer

Do you want a jagged array? (note: VB.NET also refers to jagged arrays as
"Arrays of arrays")

Dim x()() As Integer

For info on arrays in VB.NET see:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn7/html/vbconArrays.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbls7/html/vblrfVBSpec6_8.asp

Or are you asking about something entirely different? ;-)

Hope this helps
Jay
 
Back
Top