|
-
Mar 20th, 2003, 05:57 PM
#1
Thread Starter
Hyperactive Member
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
-
Mar 20th, 2003, 06:00 PM
#2
VB Code:
'...
Forms(lngFormIndex&).txtOut.SetFocus
Else
Dim frmNewIM As New frmIM
With frmNewIM
.Caption = a(2)
.Tag = LCase(a(2))
.Show
End With
[b]End If[/b]
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
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
-
Mar 20th, 2003, 06:01 PM
#3
Frenzied Member
See in changes RED
VB 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
[color="red"]End If[/color]
End Select
Case "NEXT HERE"
'blah
End Select
End If
Next
End Sub
-
Mar 20th, 2003, 06:03 PM
#4
Thread Starter
Hyperactive Member
Damn mistakes, Thanks alot
Kevin Carpenter
Currently Working in the CAOS (CA Operating System) Group
-
Mar 20th, 2003, 08:26 PM
#5
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|