Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted
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.
Posted
   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

"Who is John Galt?"
  • Leaders
Posted

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.

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...