Results 1 to 2 of 2

Thread: If statement problem

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2004
    Posts
    14

    If statement problem

    ok heres the code

    Code:
    If Split(sdata, "*/*")(0) = "handle" Then
    
                'Checks if user needs permission to view!
                If preference.Check16.Value = 1 Then
                 Dim Form As Form
                 Dim winsockindex1 As String
                 Dim requestpermission As Form
                 Set requestpermission = New requestpermission
                 requestpermission.Tag = "camrequest" & Split(sdata, "*/*")(1)
                 winsockindex1 = camview(Index).Index
                 'sets the varables to what is needed
                 For Each Form In Forms
                  If Form.Tag = "camrequest" & Split(sdata, "*/*")(1) Then Text1.Text = winsockindex1
                 Next
                 End If
                 For Each Form In Forms
                 If Form.Tag = "camrequest" & Split(sdata, "*/*")(1) Then Label1.Caption = Split(sdata, "*/*")(1) & " is asking you to view your webcam would you like to grant this request?"
                Next
                End If
                
                 Exit Sub
                End If
    ok I need the first if to stay open but the ones if form.tag i want to close them
    and the "If preference.Check16.Value = 1 Then " i also want closed And the problem is im gettin an end if error.

    the first if goes onto other ifs.

    Does anybody know if im puttin the end if's in the wrong place or what?

    Thanks!

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    You have one to many End Ifs. Indenting your code would find these errors easily. If statements written completely on one line do not require an End If.


    VB Code:
    1. If Split(sdata, "*/*")(0) = "handle" Then
    2.  
    3.     'Checks if user needs permission to view!
    4.     If preference.Check16.Value = 1 Then
    5.    
    6.         Dim Form As Form
    7.         Dim winsockindex1 As String
    8.         Dim requestpermission As Form
    9.              
    10.         Set requestpermission = New requestpermission
    11.         requestpermission.Tag = "camrequest" & Split(sdata, "*/*")(1)
    12.         winsockindex1 = camview(Index).Index
    13.        
    14.         'sets the varables to what is needed
    15.         For Each Form In Forms
    16.             If Form.Tag = "camrequest" & Split(sdata, "*/*")(1) Then Text1.Text = winsockindex1
    17.         Next
    18.              
    19.     End If 'for If preference.check16.value
    20.    
    21.     For Each Form In Forms
    22.         If Form.Tag = "camrequest" & Split(sdata, "*/*")(1) Then Label1.Caption = Split(sdata, "*/*")(1) & " is asking you to view your webcam would you like to grant this request?"
    23.     Next
    24. End If 'for If Split...
    25.          
    26. Exit Sub
    27.            
    28. End If 'Extra End If

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