Bookshelf Home | Contents | Index | PDF |
Siebel VB Language Reference > VB Language Reference > GoTo StatementThis standard VB method transfers program control to a specified label. SyntaxReturnsUsageA label has the same format as any other Basic name. Reserved words are not valid labels. GoTo cannot be used to transfer control out of the current Function or Subprogram. ExampleThis example displays the date for one week from the date entered by the user. If the date is invalid, the GoTo statement sends program execution back to the beginning. Sub Button_Click NOTE: Good programming practice is to avoid the use of GoTo statements. When possible, other constructs should be used to accomplish the same end. For example, the previous example could be reworked so that the If statement appears in a separate function called by the main program. If the test failed, the initial routine could be called again. The following example demonstrates this alternative. (general) (declarations) Function CheckResponse(Answer) As String Sub Button1_Click See AlsoDo...Loop Statement |
Siebel VB Language Reference |