Re: how to 10 per line this code help newbie in vb.net
Hi, but I'm not sure what you are actually looking for. I'm not sure what 10 per line means.
Also, don't forget you can copy and paste code and use the [ code ] [ / code ] tags (no spaces).
Assuming you want more than one number to appear on each line, it can be done this way, using a counter which counts how many numbers are being printed on the current line.
vb Code:
Dim NumbersOnLine As Integer = 0 ' Counts how many numbers there are on the current line.
Dim Max As Integer = 10 ' How many numbers will be on one line.
For counter As Integer = 0 To 200
If counter Mod 5 = 0 OrElse counter Mod 6 = 0 Then
NumbersOnLine += 1
Console.Write(counter)
If NumbersOnLine < Max Then ' Continues the line.
Console.Write(", ")
Else
Console.WriteLine() ' Starts a new line if the numbers on that line has reached the max.
NumbersOnLine = 0
End If
End If
Next
Console.ReadLine()
There are obviously plenty of ways to accomplish this, this is just one way I chose.
Re: how to 10 per line this code help newbie in vb.net
Originally Posted by NinjaNic
Hi, but I'm not sure what you are actually looking for. I'm not sure what 10 per line means.
Also, don't forget you can copy and paste code and use the [ code ] [ / code ] tags (no spaces).
Assuming you want more than one number to appear on each line, it can be done this way, using a counter which counts how many numbers are being printed on the current line.
vb Code:
Dim NumbersOnLine As Integer = 0 ' Counts how many numbers there are on the current line.
Dim Max As Integer = 10 ' How many numbers will be on one line.
For counter As Integer = 0 To 200
If counter Mod 5 = 0 OrElse counter Mod 6 = 0 Then
NumbersOnLine += 1
Console.Write(counter)
If NumbersOnLine < Max Then ' Continues the line.
Console.Write(", ")
Else
Console.WriteLine() ' Starts a new line if the numbers on that line has reached the max.
NumbersOnLine = 0
End If
End If
Next
Console.ReadLine()
There are obviously plenty of ways to accomplish this, this is just one way I chose.
Good luck!
~Nic
Thank a lot master it works someday I will be easy for this thank man
Re: how to 10 per line this code help newbie in vb.net
[QUOTE=NinjaNic;5142741]Hi, but I'm not sure what you are actually looking for. I'm not sure what 10 per line means.
Also, don't forget you can copy and paste code and use the [ code ] [ / code ] tags (no spaces).
Assuming you want more than one number to appear on each line, it can be done this way, using a counter which counts how many numbers are being printed on the current line.
vb Code:
Dim NumbersOnLine As Integer = 0 ' Counts how many numbers there are on the current line.
Dim Max As Integer = 10 ' How many numbers will be on one line.
For counter As Integer = 0 To 200
If counter Mod 5 = 0 OrElse counter Mod 6 = 0 Then
NumbersOnLine += 1
Console.Write(counter)
If NumbersOnLine < Max Then ' Continues the line.
Console.Write(", ")
Else
Console.WriteLine() ' Starts a new line if the numbers on that line has reached the max.
NumbersOnLine = 0
End If
End If
Next
Console.ReadLine()
There are obviously plenty of ways to accomplish this, this is just one way I chose.
Good luck!
~Nic
Last edited by TABILIN; Feb 23rd, 2017 at 10:54 PM.
Re: how to 10 per line this code help newbie in vb.net
Well, I don't think I should do the code for you.
But I have an idea of how you should approach this.
Create an array of [1, 2, 3, 4, 5, 6] and print it out.
Use a for loop 6 times, decrementing each number by 1.
If the number is 0, do not decrement it.
When printing out, if the number is zero, print a space.
Good luck! If you have some code written down, I would be more than happy to help critique it.
Re: how to 10 per line this code help newbie in vb.net
Originally Posted by NinjaNic
Well, I don't think I should do the code for you.
But I have an idea of how you should approach this.
Create an array of [1, 2, 3, 4, 5, 6] and print it out.
Use a for loop 6 times, decrementing each number by 1.
If the number is 0, do not decrement it.
When printing out, if the number is zero, print a space.
Good luck! If you have some code written down, I would be more than happy to help critique it.
ey bro what the problem of this when I run this code
Sub Main()
Dim i, j As Integer
For i = 1 To 6
For j = 1 To i
Console.Write(j & " ")
Next
Console.WriteLine()
Next
Console.ReadKey()
End Sub
1
12
123
1234
12345
123456
instead of this: pls help me bro I want to pass this day
123456
12345
1234
123
12
1
help me bro I wanto sumbit this casestudy huhu!