Results 1 to 7 of 7

Thread: [RESOLVED] [Solved] VBScript: Split String...

  1. #1

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065

    Resolved [RESOLVED] [Solved] VBScript: Split String...

    Hi guys,,

    I need to split incoming data into seperate items of an array... now in Visual Basic this is easy...

    in VBScript: i dunno why but its crapped up.

    I need to use it like the following:

    VB Code:
    1. Sub wskScript_DataArrival(Index, bytesTotal)
    2. 'On Error GoTo ErrHand:
    3. 'On Error Resume Next
    4.  
    5.     Dim SplitDataA(), DataArrival(), DataRecieved
    6.     Dim i
    7.    
    8.     wskScript(0).GetData DataRecieved, vbString
    9.    
    10.     SplitDataA() = Split(DataRecieved, " ## ")
    11.    
    12.     For i = 1 To UBound(SplitDataA())
    13.         DataArrival() = Split(SplitDataA(i), " :$: ")
    14.        
    15.         Select Case DataArrival(0)

    only problem is:

    when i get to the following code:

    VB Code:
    1. SplitDataA() = Split(DataRecieved, " ## ")

    i get the following error come up:

    Error> 9 - Subscript out of range: 'SplitDataA' on line 145
    has anybody got a clue of why this error is coming up?...

    i know for a fact data is coming, cuz i added a message box like:
    Code:
        wskScript(0).GetData DataRecieved, vbString
    msgbox DataRecieved
    and it come up with:
    ---------------------------
    VBScript
    ---------------------------
    ## cmdDL :$: LT ## cmdSN :$: 127.0.0.1
    ---------------------------
    OK
    ---------------------------
    anyone got a clue on dis one?.. its prolly jst the fact of the vb / vbscript differences.... but :shrugs:
    Last edited by wpearsall; Feb 1st, 2004 at 04:37 PM.
    Wayne

  2. #2
    Member Tom77757's Avatar
    Join Date
    Dec 2003
    Location
    New Jersey, USA
    Posts
    45
    SplitDataA() = Split(DataRecieved, " ## ")
    try removing the spaces before and after the # sign..
    I hope this Helps !!

    Good Luck,
    Tom
    Microsoft Most Valuable Professional Award [ MVP]. mvp.support.microsoft.com

    "When there is the will !!! There is the mind for it !."

  3. #3

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    i need the spaces.... cant remove em, since they are the seperater between diff things in data which is sent...
    Wayne

  4. #4
    Frenzied Member
    Join Date
    May 2003
    Location
    So Cal
    Posts
    1,564

  5. #5
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    VB Code:
    1. Dim SplitDataA As String
    2. Dim DataArrival As String
    3. Dim i As Integer
    4. Dim j As Integer
    5.  
    6. SplitDataA = Split(DataRecieved, " ## ")
    7.  
    8. For i = 0 To UBound(SplitDataA)
    9.    DataArrival = Split(SplitDataA(i), " :$: ")
    10.    
    11.    For j = 0 To UBound(DataArrival)
    12.       Select Case DataArrival(0)
    13.          'do something
    14.    Next
    15. Next
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  6. #6
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Okinawa, Japan
    Posts
    271
    Dont define SplitDataA or DataArrival as array.

    So Should be

    VB Code:
    1. Sub wskScript_DataArrival(Index, bytesTotal)
    2. 'On Error GoTo ErrHand:
    3. 'On Error Resume Next
    4.  
    5.     Dim SplitDataA, DataArrival, DataRecieved
    6.     Dim i
    7.    
    8.     wskScript(0).GetData DataRecieved, vbString
    9.    
    10.     SplitDataA = Split(DataRecieved, " ## ")
    11.    
    12.     For i = 1 To UBound(SplitDataA)
    13.         DataArrival = Split(SplitDataA(i), " :$: ")
    14.        
    15.         Select Case DataArrival(0)

    packetvb

  7. #7

    Thread Starter
    Frenzied Member wpearsall's Avatar
    Join Date
    Feb 2002
    Location
    England / UK
    Posts
    1,065
    Originally posted by Memnoch1207
    VB Code:
    1. Dim SplitDataA As String
    2. Dim DataArrival As String
    3. Dim i As Integer
    4. Dim j As Integer
    5.  
    6. SplitDataA = Split(DataRecieved, " ## ")
    thanks memnock....

    fixed ma problem (eh, was a diff between the two langs eh... vb needs (), and vbs dont )
    Wayne

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width