Solved

Split data in winsock

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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

832 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