Results 1 to 5 of 5

Thread: For Next loop

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 1999
    Posts
    36

    Post

    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!!

  2. #2
    Member
    Join Date
    Nov 1999
    Location
    panama
    Posts
    57

    Post

    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

  3. #3
    Junior Member
    Join Date
    Oct 1999
    Posts
    31

    Post

    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.

  4. #4

    Thread Starter
    Member
    Join Date
    Nov 1999
    Posts
    36

    Post

    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????

  5. #5
    Junior Member
    Join Date
    Oct 1999
    Posts
    31

    Post

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width