Results 1 to 2 of 2

Thread: Split command doesn't work...

  1. #1

    Thread Starter
    Hyperactive Member tomcatexodus's Avatar
    Join Date
    Feb 2001
    Posts
    372

    Unhappy

    Ok, well, its not that the 'SPLIT' command doesn't work, it's because I'm using VB 1.0 DOS, (And I have a good reason to do it.) for console applications... anyways, I need to determine what the user enters at the command prompt by using COMMAND$, and I need to 'split' up the COMMAND$ variable to determine what to do. For example:

    netshlr -connect:127.0.0.1 -ping:1

    How could I 'split' this up, keeping in mind I don't have access to the SPLIT command???
    IWS

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    this was built for 5 but maybe it will work for you
    Code:
    'VB5 Split Function 
    'split function for VB5 and under vb6 has the function 
    'posted originally by Aaron Young 
    
    Public Function Split2(ByVal sString As String, ByVal sSeparator As String) As Variant 
    Dim sParts() As String 
    Dim lParts As Long 
    Dim lPos As Long 
    
    lPos = InStr(sString, sSeparator) 
    While lPos 
    ReDim Preserve sParts(lParts) 
    sParts(lParts) = Left(sString, lPos - 1) 
    sString = Mid(sString, lPos + Len(sSeparator)) 
    lPos = InStr(sString, sSeparator) 
    lParts = lParts + 1 
    Wend 
    If Len(sString) Then 
    ReDim Preserve sParts(lParts) 
    sParts(lParts) = sString 
    End If 
    Split2 = IIf(lParts, sParts, Array()) 
    End Function 
    
    'Example: 
    
    Private Sub Form_Load() 
    Dim vLines As Variant 
    Dim lLine As Long 
    
    vLines = Split2("Line1,Line2,Line3", ",") 
    For lLine = 0 To UBound(vLines) 
    List1.AddItem vLines(lLine) 
    Next 
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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