Solved

Split data in winsock

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Notepad++ how to remove delimiter : from beggning of the line? 3 114
Getting warning: You are about to delete 1 row(s) 9 52
Sub or Function is not defined 6 43
Link failure 16 34
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This video teaches viewers about errors in exception handling.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

828 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