By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,927 Members | 1,751 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,927 IT Pros & Developers. It's quick & easy.

rerun code

P: n/a
Hi,

how can I get my forms program to perform a particular action again if
the incorrect format is entered,

I have tried

GOTO line xxx
but this did not work, Is there something like GOTO beginning?

thanks

Portroe

Nov 20 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
GoTo Statement
See Also
Do...Loop Statements | For...Next Statements | If...Then...Else Statements |
Select...Case Statements | Try...Catch...Finally Statements
Branches unconditionally to a specified line within a procedure.
GoTo line
Part
line
Required. Any line label.
Remarks
GoTo can branch only to lines within the procedure where it appears.
You cannot use a GoTo to branch from outside a For...Next, For Each...Next,
SyncLock...End SyncLock, Try...Catch...Finally, or With...End With block to
a label inside.
Within a Try...Catch...Finally construction, you cannot use GoTo to branch
out of a Try block, into a Catch block, or into or out of a Finally block.
You can branch from a Catch block into the Try block associated with that
Catch. For example, if one Try...Catch...Finally construction is nested
within another, a Catch block can branch into the Try block at its own
nesting level, but not into any other Try block.
Note GoTo statements can make code difficult to read and maintain.
Whenever possible, use Do...Loop, For...Next, If...Then...Else, Select Case,
Try...Catch...Finally, While, and With...End With structures instead.
Example
This example uses the GoTo statement to branch to line labels within a
procedure.
Sub GotoStatementDemo()
Dim Number As Integer
dim MyString As String
Number = 1 ' Initialize variable.
' Evaluate Number and branch to appropriate label.
If Number = 1 Then GoTo Line1 Else GoTo Line2

Line1:
MyString = "Number equals 1"
GoTo LastLine ' Go to LastLine.
Line2:
' The following statement never gets executed because Number = 1.
MyString = "Number equals 2"
LastLine:
' Print "Number equals 1" in the Output window.
Debug.WriteLine (MyString)
End Sub
Nov 20 '05 #2

P: n/a
"portroe" <bo*@sleigh.com> schrieb

how can I get my forms program to perform a particular action again
if the incorrect format is entered,

I have tried

GOTO line xxx
but this did not work,
Why?
Is there something like GOTO beginning?


Yes, there is still GOTO but you should consider reading the following
topic:
http://msdn.microsoft.com/library/en...Structures.asp
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #3

P: n/a
* portroe <bo*@sleigh.com> scripsit:
how can I get my forms program to perform a particular action again if
the incorrect format is entered,

I have tried

GOTO line xxx


Call the procedure again and exit it:

\\\
Public Sub FooBar()
If ... Then
FooBar()
Exit Sub
End If
End Sub
///

Alternatively, you may want to use a loop, but this depends on the case.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

P: n/a
Cor
Hi Herfried,

This is the same as the ones I love with a new instance of the class itself.
I hope he has enough memory you write always when I do this with a class.
:-))
Cor
\\\
Public Sub FooBar()
If ... Then
FooBar()
Exit Sub
End If
End Sub
///

Nov 20 '05 #5

P: n/a
* "Cor" <no*@non.com> scripsit:
This is the same as the ones I love with a new instance of the class itself.
I hope he has enough memory you write always when I do this with a class.
:-))


ACK... That's the problem of recursive function calls. But sometimes
it's useful...

;->

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.