Results 1 to 5 of 5

Thread: Weird error...

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Posts
    296

    Weird error...

    Code:
    Private Sub wsk_DataArrival(ByVal bytesTotal As Long)
        Dim strData As String
        wsk.GetData strData
        
        Dim b() As String
        b() = Split(strData, vbCrLf)
        
        Dim x As Integer
        Dim a() As String
        Dim i As Integer
            
        For x = 0 To UBound(b)
                   
            a() = Split(b(x), " ", 3)
            
            If UBound(a) > 0 Then
                Select Case a(0)
                Case "BUDDY"
                    If a(1) = "ONLINE" Then
                        frmBuddies.List1.AddItem (a(2))
                        StatusBar1.Panels(1).Text = "Online!"
                    Else
                        For i = 0 To frmBuddies.List1.ListCount
                            If frmBuddies.List1.List(i) = a(2) Then
                                frmBuddies.List1.RemoveItem i
                            End If
                        Next
                    End If
                Case "CLOSE"
                    wsk.Close
                    
                Case "ERROR"
                    MsgBox Left(a(1), 1)
                    
                    
                Case "XOP"
                    Select Case a(3) 'NEEDS To BE 2 WHEN SERVER IS FIXED!
                    
                        Case "PRIVMSG"
                            Dim arrInfo() As String
                            arrInfo() = Split(a(2), " ")
                            Dim lngFormIndex As Long
                            lngFormIndex& = FormByTag(LCase(a(2))) 'LCase(Replace(tvwBuddies.SelectedItem.Text, " ", "")))
                            If lngFormIndex& > -1 Then
                                Forms(lngFormIndex&).SetFocus
                                Forms(lngFormIndex&).txtIN.Text = Forms(lngFormIndex&).txtIN.Text & Forms(lngFormIndex&).Caption & ": " & a(4) & vbNewLine
                                Forms(lngFormIndex&).txtIN.SelStart = Len(Forms(lngFormIndex&).txtIN)
                                Forms(lngFormIndex&).txtOut.SetFocus
                            Else
                                Dim frmNewIM As New frmIM
                                With frmNewIM
    
                                    .Caption = a(2)
                                    .Tag = LCase(a(2))
                                    .Show
                                End With
                                lngFormIndex& = FormByTag(LCase(a(2)))
                                Forms(lngFormIndex&).SetFocus
                                Forms(lngFormIndex&).txtIN.Text = Forms(lngFormIndex&).txtIN.Text & Forms(lngFormIndex&).Caption & ": " & a(4) & vbNewLine
                                Forms(lngFormIndex&).txtIN.SelStart = Len(Forms(lngFormIndex&).txtIN) - 1
                                Forms(lngFormIndex&).txtOut.SetFocus
                    End Select
                    
                Case "NEXT HERE"
                    'blah
                End Select
            End If
        Next
    End Sub
    This code returns "End Select without Select case" and hightlights the FIRST End Select if you read from the top.

    If you want to put this in VB and see whats wtong, he is a function that is used in the top code:

    Code:
    Public Function FormByTag(strMatch As String) As Long
      Dim lngDo As Long, lngFound As Long
      lngFound& = -1
      For lngDo& = 0 To Forms.Count - 1
        If Forms(lngDo&).Tag = strMatch$ Then
          lngFound& = lngDo&
          'Forms(lngFound&).txtMessage.Text = strMessage
          Exit For
        End If
      Next
      FormByTag& = lngFound&
      'Forms(FormByTag&).txtMessage.Text = strMessage
    End Function


    Thanks alot!
    Kevin Carpenter
    Currently Working in the CAOS (CA Operating System) Group

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    VB Code:
    1. '...
    2.                             Forms(lngFormIndex&).txtOut.SetFocus
    3.                         Else
    4.                             Dim frmNewIM As New frmIM
    5.                             With frmNewIM
    6.  
    7.                                 .Caption = a(2)
    8.                                 .Tag = LCase(a(2))
    9.                                 .Show
    10.                             End With
    11.                         [b]End If[/b]
    12.                             lngFormIndex& = FormByTag(LCase(a(2)))
    13.                             Forms(lngFormIndex&).SetFocus
    14.                             Forms(lngFormIndex&).txtIN.Text = Forms(lngFormIndex&).txtIN.Text & Forms(lngFormIndex&).Caption & ": " & a(4) & vbNewLine
    15.                             Forms(lngFormIndex&).txtIN.SelStart = Len(Forms(lngFormIndex&).txtIN) - 1
    16.                             Forms(lngFormIndex&).txtOut.SetFocus
    17.                 End Select

    You were missing an End If.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Frenzied Member andreys's Avatar
    Join Date
    Sep 2002
    Location
    Los Angeles
    Posts
    1,615
    See in changes RED

    VB Code:
    1. Private Sub wsk_DataArrival(ByVal bytesTotal As Long)
    2.     Dim strData As String
    3.     wsk.GetData strData
    4.    
    5.     Dim b() As String
    6.     b() = Split(strData, vbCrLf)
    7.    
    8.     Dim x As Integer
    9.     Dim a() As String
    10.     Dim i As Integer
    11.        
    12.     For x = 0 To UBound(b)
    13.                
    14.         a() = Split(b(x), " ", 3)
    15.        
    16.         If UBound(a) > 0 Then
    17.             Select Case a(0)
    18.             Case "BUDDY"
    19.                 If a(1) = "ONLINE" Then
    20.                     frmBuddies.List1.AddItem (a(2))
    21.                     StatusBar1.Panels(1).Text = "Online!"
    22.                 Else
    23.                     For i = 0 To frmBuddies.List1.ListCount
    24.                         If frmBuddies.List1.List(i) = a(2) Then
    25.                             frmBuddies.List1.RemoveItem i
    26.                         End If
    27.                     Next
    28.                 End If
    29.             Case "CLOSE"
    30.                 wsk.Close
    31.                
    32.             Case "ERROR"
    33.                 MsgBox Left(a(1), 1)
    34.                
    35.                
    36.             Case "XOP"
    37.                 Select Case a(3) 'NEEDS To BE 2 WHEN SERVER IS FIXED!
    38.                
    39.                     Case "PRIVMSG"
    40.                         Dim arrInfo() As String
    41.                         arrInfo() = Split(a(2), " ")
    42.                         Dim lngFormIndex As Long
    43.                         lngFormIndex& = FormByTag(LCase(a(2))) 'LCase(Replace(tvwBuddies.SelectedItem.Text, " ", "")))
    44.                         If lngFormIndex& > -1 Then
    45.                             Forms(lngFormIndex&).SetFocus
    46.                             Forms(lngFormIndex&).txtIN.Text = Forms(lngFormIndex&).txtIN.Text & Forms(lngFormIndex&).Caption & ": " & a(4) & vbNewLine
    47.                             Forms(lngFormIndex&).txtIN.SelStart = Len(Forms(lngFormIndex&).txtIN)
    48.                             Forms(lngFormIndex&).txtOut.SetFocus
    49.                         Else
    50.                             Dim frmNewIM As New frmIM
    51.                             With frmNewIM
    52.  
    53.                                 .Caption = a(2)
    54.                                 .Tag = LCase(a(2))
    55.                                 .Show
    56.                             End With
    57.                             lngFormIndex& = FormByTag(LCase(a(2)))
    58.                             Forms(lngFormIndex&).SetFocus
    59.                             Forms(lngFormIndex&).txtIN.Text = Forms(lngFormIndex&).txtIN.Text & Forms(lngFormIndex&).Caption & ": " & a(4) & vbNewLine
    60.                             Forms(lngFormIndex&).txtIN.SelStart = Len(Forms(lngFormIndex&).txtIN) - 1
    61.                             Forms(lngFormIndex&).txtOut.SetFocus
    62.                         [color="red"]End If[/color]
    63.                 End Select
    64.                
    65.             Case "NEXT HERE"
    66.                 'blah
    67.             End Select
    68.         End If
    69.     Next
    70. End Sub

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Posts
    296
    Damn mistakes, Thanks alot
    Kevin Carpenter
    Currently Working in the CAOS (CA Operating System) Group

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2002
    Posts
    296
    Does anyone have a better way of sorting privates messages than what I have above? Thanks.
    Kevin Carpenter
    Currently Working in the CAOS (CA Operating System) Group

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