Error Handling Problem

JMorgan
06-01-2005, 10:46 AM
Private Sub Command1_Click()
Dim Index As Integer
Dim Errors As Boolean
On Error GoTo ErrorHandler
Index = 0
Errors = False
Do While Errors = False And Index < 81
If txtNumber(Index).Text <> "" Then
If (txtNumber(Index).Text < 0) Or (txtNumber(Index).Text > 9) Then
Errors = True
MsgBox "Numbers can only take values between 0 and 9", vbInformation, "Error"
End If
End If
Index = Index + 1
Loop
For Index = 0 To 80
If txtNumber(Index).Text = "" Then
Number(Index) = 0
Else: Number(Index) = txtNumber(Index).Text
End If
Next Index
End Sub
ErrorHandler:
MsgBox "Numbers do not contain characters", vbCritical, "Error"
End Sub
The error i get is label not defined, how shall i solve this problem.

spikey_richie
06-01-2005, 10:55 AM
You need an exit sub not end sub before the ErrorHandler:

spikey_richie
06-01-2005, 10:58 AM
I commented out all of the code


For Index = 0 To 80
If txtNumber(Index).Text = "" Then
Number(Index) = 0
Else: Number(Index) = txtNumber(Index).Text
End If
Next Index


and it works. Maybe something in there.

JMorgan
06-01-2005, 11:01 AM
Thank You

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum