Lanc1988 Posted February 13, 2005 Posted February 13, 2005 I have a large section of code then after all of it i have the following code: If lblHits.Text = "" Then Current = boxHits.Text CurrentAsLevel = boxHits.Text If boxHits.Text < 100 Then lblHits3.Text = boxHits.Text lblHitsExp.Text = "(" & Current & "exp.)" ElseIf boxHits.Text > 100 Then lblHits3.Text = CurrentAsLevel lblHitsExp.Text = "(" & boxHits.Text & " exp.)" End If 'Loop or go back to top code needs to go here End If Is there a way to add a loop, or go back to top code where i marked it in my code so that it will go to the top and start over? Because for the Current and CurrentAsLevel things get their value from the large section of code at the top. I have about 20 things to add the code for that i posted above. I added the If lblHits.Text = "" so that it wont redo a section that already has a value. Quote
Lanc1988 Posted February 13, 2005 Author Posted February 13, 2005 Is there some kind of code that is like "GoTo 1".. ive seen something for the On Error Goto 1 or something like that and it will go to a certain area of the code. Quote
IngisKahn Posted February 14, 2005 Posted February 14, 2005 Do '... If lblHits.Text = "" Then Current = boxHits.Text CurrentAsLevel = boxHits.Text If boxHits.Text < 100 Then lblHits3.Text = boxHits.Text lblHitsExp.Text = "(" & Current & "exp.)" ElseIf boxHits.Text > 100 Then lblHits3.Text = CurrentAsLevel lblHitsExp.Text = "(" & boxHits.Text & " exp.)" End If Else Exit Do End If Loop Quote "Who is John Galt?"
michael_hk Posted February 14, 2005 Posted February 14, 2005 Take a look the entry "GoTo" in the documentation, I don't think it is a good practice to use it though. Quote There is no spoon. <<The Matrix>>
Leaders snarfblam Posted February 14, 2005 Leaders Posted February 14, 2005 Huh, I actually thought that they had done away with goto like they did gosub. Structured programming has nearly rendered it useless anyways but... Put a "Do" on the line you want to go to. Put a "Loop While <Condition>" on the line that you want to go back to. If <Condition> evaluates to True then the program will branch to the line after the "Do". I beleive in your case this performs the exact same function Goto would for you. Quote [sIGPIC]e[/sIGPIC]
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.