Solved

Split data in winsock

Posted on 2003-12-05
3
425 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 86

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
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…

752 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