Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Split data in winsock

Posted on 2003-12-05
3
Medium Priority
?
428 Views
Last Modified: 2013-11-13

Dim tempData() As String
Dim i As Long
'tempdata will be something like "a" & chr$(0) & "blah" & Chr$(1)
Winsock.GetData tempData    
    tempData = Split(tempData, Chr$(1))
   
    For i = LBound(tempData) To UBound(tempData)
        msg = Split(tempData, Chr$(0))
        Select Case msg(0)
            Case "a"
                MsgBox "blah"
            Case "b"
                MsgBox "bleh"
        End Select
     
    Next i

Is there anything wrong with the code ? cos i got an error ..
0
Comment
Question by:vbaddictor
3 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 200 total points
ID: 9885577
It should be more like this:

    Dim tempData As Variant
    Dim msg As Variant
   
    Dim inputData As String
    Dim i As Long

    'tempdata will be something like "a" & chr$(0) & "blah" & Chr$(1)
    Winsock.GetData inputData, vbString
    tempData = Split(inputData, Chr$(1))
   
    For i = LBound(tempData) To UBound(tempData)
        msg = Split(tempData, Chr$(0))
        Select Case msg(0)
            Case "a"
                MsgBox "blah"
            Case "b"
                MsgBox "bleh"
        End Select
    Next i
0
 
LVL 10

Expert Comment

by:anv
ID: 9887221
'try this
Dim tempData As Variant
    Dim msg As Variant
   
    Dim inputData As String
    Dim i As Long

    'tempdata will be something like "a" & chr$(0) & "blah" & Chr$(1)
    Winsock.GetData inputData, vbString
    tempData = Split(inputData, Chr$(0))(0)

    Select Case tempdata
            Case "a"
                MsgBox "blah"
            Case "b"
                MsgBox "bleh"
        End Select

   
0
 

Author Comment

by:vbaddictor
ID: 9892022
Idle_Mind, but i have solved that problem by adding -1

 tempData = Split(inputData, Chr$(1))
   
    For i = LBound(tempData) To UBound(tempData) -1 '<---

and it wont gives me any error .... do u think it's working correctly ?
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question