Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comman-Line Parameter into VB6

Status
Not open for further replies.

tc3596

Technical User
Mar 16, 2001
283
From VBA I am trying to call a VB exe and pass it some parameters. However, it is not working. Nothing seems to be getting passed. Here is my call and VB code.

CALL
Shell "C:\prjIconAutoSync.exe dice"

VB CODE
Sub Main()


Dim aryargs

MsgBox Command

If Command <> "" Then
aryargs = Split(Command, ",")

mServer = aryargs(0)

End if





End Sub



A message box displays, but it's empty. I tried setting command line parameters in the Make tab of the exe for testing, but still nothing. I also tried calling this via the real command line, and still an empty message box. Seems like this should work, but I am obvisouly missing something. Any thoughts are appeciated.
 
I've been thinking about this for a while now. I even wrote a little app and tested it. It seemed to work as I expected it to (message box with the argument displayed). So, I thought a little more, and came up with this:

Now, this is just a thought, but it's something you should check. In VB6, you can control the 'Startup Object'. You are limited in your choices. You can choose 'Sub Main' or any form in your application.

Since you apparently want to use 'Sub Main' you need to make sure that it's selected as your start up object.

In the VB6 IDE...

Click Project -> 'Project name' Properties.
On the 'General Tab' (Upper right corner), you will see 'Startup Object'. Make sure this is set to 'Sub Main'.

I hope this helps.


-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
A message box displays, but it's empty.
I tried setting command line parameters in the Make tab of the exe for testing, but still nothing.

So, it appears that Sub Main is being called, and even adding the arg in the Make tab doesn't produce results.

Maybe "Command" is declared as a variable, such as at the top of the module, or as a public variable somewhere else in the programm.
That would then produce that result.

Try using:
msgbox Command()

If that doesn't help, then Command could be a property or method defined by the programmer somewhere. So, do a search through all the code using:

Command(
 
>If that doesn't help, then Command could be a property or method defined by the programmer somewhere

I would strongly suspect this as the culprit. Even just a public variable called Command (defined as a string) would cause the problem, so I'd search without the bracket ...
 

yes, I think yo too, as I mentioned it could be both.

Therefore, for the variable possibility, (and it doesn't need to be public if at the top of the same module), using MsgBox Command() would throw an error right away, and that was my first thought to test that possibility quickly.
 
>yes, I think yo too, as I mentioned it could be both[one or the other]


Which would mean

MsgBox VBA.Command()

should work.
 
I'm just skimming the thread too quickly. You did indeed mention the possibility in your post. I'll just move along ... ;-)
 
I have tried to use Command to extract the name of the target file when you associate your app with a file but that does not seem to work either.

I wanted to show a shockwave in a homemade version of a shockwave player, and run it simply by clicking on the SWF file (not previously having run my app) how do I get the file name into my app when I just click on that file in Windows Explorer?

By associating my app with that file it just opens my app but does not load the text file automatically. I have to select from a Commondialog manually to get it to work.

I used
Sub Form Load()
Dim Filename as string
Filename=Command
If Filename>"" then Shockwaveflash1.LoadMovie 0,Filename
End Sub

Is that what it is supposed to do or is there another method I should be using for associated files?
 
Thank you for all of your responses...In doing my own testing, I had a reference to one of the dll's that my company uses for programming within its own environment. It appears that if I release this reference then the "Command" returns the parameters, but with it it does not. My only thought is that they share the same key work "Command".
 
Yep, that's what we said.

So using explicit referencing should work:

VBA.Command()

MyDll.Command
 
someone gave me something like "microsoft.vbscripting." to add in front of it, but that didn't work. I ended up going a different route, but I will try vba.commmand and let you know the outcome. Thanks for your input.
 
>someone gave me something like "microsoft.vbscripting." to add in front of it,

Not in here they didn't.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top