Mega Code Archive

 
Categories / VB.Net / Language Basics
 

Use GOTO to deal with user input

Imports System Public Class MainClass    Shared Sub Main()         Dim getData As String         Dim i, j As Integer         For i = 1 To 10             For j = 1 To 100                 Console.Write("Type the data, hit the Enter key between " & _                     "Q to end:  ")                 getData = Console.ReadLine()                 If getData = "Q" Then                     GoTo BadInput                 Else                     'Process data                 End If             Next j         Next i         Exit Sub BadInput:         Console.WriteLine("Data entry ended at user request")    End Sub  End Class