PDA

Click to See Complete Forum and Search --> : For Next loop


Anita
Nov 30th, 1999, 03:41 AM
I have written the following code and it is giving a compile error" For without Next"
For ncontrolno = 0 To Employer.Controls.Count - 1
If TypeOf Employer.Controls(ncontrolno) Is TextBox Then
If Employer.Controls(ncontrolno(Index)) = 0 Then
If keyascii >= Asc("0") And keyascii <= Asc("9") Then
keyascii = 0
MsgBox "You must enter a Company Name"
Exit Sub
End If

Else
If Employer.Controls(ncontrolno(Index)) = 1 Then
If keyascii >= Asc("0") And keyascii <= Asc("9") Then
keyascii = 0
MsgBox "You must enter a Vocation"
Exit Sub
End If

Else
If Employer.Controls(ncontrolno(Index)) = 2 Then
If keyascii >= Asc("0") And keyascii <= Asc("9") Then
keyascii = 0
MsgBox "You must enter a Name"
Exit Sub
End If

Else
If Employer.Controls(ncontrolno(Index)) = 3 Then
If keyascii >= Asc("0") And keyascii <= Asc("9") Then
keyascii = 0
MsgBox "You must enter a Address"

End If
Else
If Employer.Controls(ncontrolno(Index)) = 4 Then
If keyascii >= Asc("0") And keyascii <= Asc("9") Then
keyascii = 0
MsgBox "You must enter a City"

End If
Exit Sub

End If

End If
Next

Please help me!!

carlosapv
Nov 30th, 1999, 03:48 AM
nedeed for [cycle] and the finish of the cycle [next ncontrolno] and count the if and verify if with your [end if] repectly

ok



------------------
capv

Ghost
Nov 30th, 1999, 03:52 AM
what exactly are you trying to do ? seems like you want the user to enter between 0-9. right. check for the keyascii once and then display the message accordingly.

Anita
Nov 30th, 1999, 04:07 AM
If you have a control array and want to check the index value of that control in a for next loop how do you do that????

Ghost
Nov 30th, 1999, 04:30 AM
i am assuming that your textboxes are in a control array. when the keypress event is trigerred, you will also get the index of the control for which the keypress was generated automatically. you don't have to do a for..next loop.