[RESOLVED] Do while loop question
I have this do while loop that I am having trouble with. I need to know how to make the loop continue to the next line after it has looped around once. So far I have it outputting like this.
$*$*$*$*$*$*$*$*
But what I really need it to do is output like this
$*$*$*$*$*$*$*$*
...
Re: Do while loop question
You'll want to post your code up to see how you are outputting this. Also is this homework?
__________________
A first chance exception of type 'System.NullReferenceException' occurred in Signature. Signature reference not set to an instance of an ...
Re: Do while loop question
Yes it is homework, thats why I didn't post the code, I just really want an explaination of the do while loop or for someone to guide me to a tutorial and sample about it.
Re: Do while loop question
You may think of putting another outer loop that will insert the line breaks(new line character) and also control how many lines of $*$* to put on console (may be take the user input).
Re: Do while loop question
A tutorial or sample would be doing the work for you.
If you want help you need to post your code so we can help you. It's really quite simple, all you need are two for loops, one within the other. One loops through the rows, the other columns, that's it.
...
Re: Do while loop question
Ok those both sound like great ideas thanks for the help I will have to more research on how to insert that other loop, I'm new to vb and out teacher wants us to figure out mostly everything for ourself.
There's an oddity to that pattern that will take a bit more effort. The lines alternate. If they were all the same, that would be easier, but the alternating does add a modest amount of interest, as you will need to keep track of what the starting character needs to be.
Re: Do while loop question
There's an oddity to that pattern that will take a bit more effort. The lines alternate. If they were all the same, that would be easier, but the alternating does add a modest amount of interest, as you will need to keep track of what the starting character needs to be....
Re: Do while loop question
You can check for even and odd rows to determine which character to begin with. Then just alternate between the two characters.
e.g. like this:
(not tested code)
vb.net Code:
Private Sub Button1_Click ( ByVal sender As System. Object , ByVal e As System. EventArgs ) Handles...
Re: Do while loop question
Pradeep I'm disappointed. Most of the people on the forums have picked up that you don't just give someone their homework assignment. Next time please refrain from making people's assignments for them.
__________________
If your problem is solved, click...
Re: Do while loop question
Use a counter and increment it with every loop. If n Mod 2 is 0, then output $*$*$*$*$*$*, otherwise output *$*$*$*$*$*$. Simple enough.
__________________
MINITECH, VB.NET Programmer
The #1 thing that annoys me: when people's signatures are longer...
Re: Do while loop question I finally figured it out and got it to work I was leaving out 1 small line. Thanks everyone for your help. Moving on to the final pattern.
Re: Do while loop question A while loop can do the same things a for loop does. __________________ If your problem is solved, click the Thread Tools button at the top and mark your topic as Resolved ! If someone helped you out, click the button on their post and leave them a comment to let them know they did a good job __________________ My Vb.Net CodeBank Submissions: Microsoft Calculator Clone Custom TextBox Restrictions Get the Text...
There's an oddity to that pattern that will take a bit more effort. The lines alternate. If they were all the same, that would be easier, but the alternating does add a modest amount of interest, as you will need to keep track of what the starting character needs to be.
Re: Do while loop question You'll want to post your code up to see how you are outputting this. Also is this homework? __________________ A first chance exception of type 'System.NullReferenceException' occurred in Signature. Signature reference not set to an instance of an object.
Re: Do while loop question You may think of putting another outer loop that will insert the line breaks(new line character) and also control how many lines of $*$* to put on console (may be take the user input).
Re: Do while loop question I would start with two For loops and a boolean for the last char, when the inner loops stops, set the bool to not itself then at the start of the next iteration check the bool. __________________ Currently using: VS 2005 & 2008 Pro w/sp1 on WinXP Pro w/sp3. There are 3 kinds of people in the world: Those who can count and those who can't. 4 out of 3 people have trouble with fractions. "Sleep is...
Re: Do while loop question You can check for even and odd rows to determine which character to begin with. Then just alternate between the two characters. e.g. like this: (not tested code) vb.net Code: Private Sub Button1_Click ( ByVal sender As System. Object , ByVal e As System. EventArgs ) Handles Button1. Click Const MaxRows As Integer = 10 Const MaxColumns As Integer = 15...
Re: Do while loop question Use a counter and increment it with every loop. If n Mod 2 is 0, then output $*$*$*$*$*$*, otherwise output *$*$*$*$*$*$. Simple enough. __________________ MINITECH, VB.NET Programmer The #1 thing that annoys me: when people's signatures are longer than their posts. I also don't like it when people's signatures have too much thought put into them, when you have to spend time reading them or looking...
Related threads on "VBForums - Visual Basic and VB .NET Discussions and More!":
Thread profile page for "[RESOLVED] Do while loop question" on http://www.vbforums.com.
This report page is a snippet summary view from a single thread "[RESOLVED] Do while loop question", located on the Message Board at http://www.vbforums.com.
This thread profile page shows the thread statistics for: Total Authors, Total Thread Posts, and Thread Activity