Results 1 to 2 of 2

Thread: Command as the index of an array

  1. #1

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Is that allowed if the Command is an integer?, because when I do it Command$ always comes up as EMPTY.

  2. #2
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    Hmm, the only way I can see setting Command$ as an array is to Not Use another variable, such as arrCommand$. If you're using VB6, you can then set: arrCommand$ = split(command$) ...

    Here is an example (simple one though):
    Code:
    'Code was tested and verified with VB6
    Dim arrCommand() As String
    
    Private Sub Form_Load()
        arrCommand = Split(Command$)
        For X = 0 To UBound(arrCommand)
            MsgBox arrCommand(X)
        Next X
    End Sub
    You can further set up the split by adding a delimiter to the split command.

    If using versions < 6, you may need to use the MID$ function and step through one character at a time until you hit a delimiter (or get a split function from the web).

    Code:
    'This code is NOT verified.
    Dim sLength As Integer
    Dim sTemp As String
    Dim X as Integer
    Dim Y as Integer
    
    sLenth = Len(Command$)
    ReDim arrCommand(0)
    For X = 1 to sLength
        sTemp = mid(Command$, X, 1)
        If sTemp <> " " Then
            arrCommand(Y) = arrCommand(Y) & sTemp
            Else
            Y = Y + 1
            ReDim Preserve arrCommand(Y)
        End If
    Next X
    I hope this helps
    -Excalibur

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