Solved

Split data in winsock

Posted on 2003-12-05
3
418 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 85

Accepted Solution

by:
Mike Tomlinson earned 50 total points
Comment Utility
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
Comment Utility
'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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
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.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

744 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now