Results 1 to 7 of 7

Thread: Command question

  1. #1

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    Unhappy

    In my form_load() I have this code:

    ...
    If Not (Command = "") Then
    MakeConnection
    End If
    ...
    ...
    ...
    End Sub

    I do have a MakeConnection sub defined, but when I compile and run the app with a Command, an error comes up saying:

    Runtime error '5':
    Invalid procedure call or argument.

    I've tried replacing the call to the MakeConnection sub with a MsgBox and it works, can I not call the sub like that? If so, could you tell me why not?

  2. #2

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    none of you gurus can come up with an answer?

  3. #3
    Guest
    Try this:

    Code:
    Private Sub Form_Load()
    If Command <> "" Then
    MakeConnection
    End If
    End Sub

  4. #4

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    nope, didn't work

    Isn't that just another way to write what I already have?

  5. #5
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    Here's what I tried. I didnt' see where you declared the command variable, so I just did it in the form load area.

    Code:
    Private Sub Form_Load()
        MsgBox Command$
        If Not (Command$ = "") Then
            MakeConnection
        End If
    End Sub
    
    Private Sub MakeConnection()
        MsgBox "howdy"
    End Sub
    With no command line switches, I get an empty form. when I use a commandline switch (-woop) , I got the messagebox -woop and howdy. I'm unsure why it doesn't work for you ...
    -Excalibur

  6. #6

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    maybe iif i elaborate

    the command line argument is going to be used as an index in an array, so that Command$ variable is guaranteeed to be a number. I don't know if that makes a difference or not

  7. #7
    Fanatic Member ExcalibursZone's Avatar
    Join Date
    Feb 2000
    Location
    Western NY State
    Posts
    908
    I tested my compiled 'test' project with just a number and it worked fine. Just make sure you convert the string into a number before using it as a number for an array. and also make sure that you have the array Dim'ed to that number or you'll have problems (ReDim Preserve ArrayName (Val(Command$)) ...

    -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