I need to pass a value to an external VB application from a Web page. I would like to use something like "program.exe -q12345" where 12345 is a record number in a database. Can this be done?<br>
<br>
Please help.
Assuming you are the developer of said VB app, you have to enable the startup object (form or main sub) to accept this argumant. There is a VB function called 'Command$' that does this very thing.<br>
<br>
The code in your app would look something like this (a form is the startup object in this case)"<br>
<br>
sub Form_Load()<br>
dim sArg as string<br>
dim iQ as integer<br>
dim iSpace as integer<br>
dim sRec as string<br>
dim lRec as long<br>
<br>
'get command line arguments<br>
sArg = Command$()<br>
<br>
if len(sArg) then<br>
'look for '-q'<br>
iQ = instr(lcase$(sArg), "-q"<br>
<br>
if iQ then<br>
'iQ exists, look for space after iQ<br>
iSpace = instr(iQ+2, sArg, " "<br>
if iSpace > 0 then<br>
'get characters between iQ and space<br>
sRec = mid$(sArg, iQ+2, iSpace-iQ-2)<br>
else<br>
'get all characters after iQ <br>
sRec = mid$(sArg, iQ+2)<br>
end if<br>
<br>
if isnumeric(sRec) then<br>
lRec = val(sRec)<br>
bResult = GoGetDatabaseRecord(lRec)<br>
else<br>
'non numeric data has been passed in<br>
'cannot retrieve record by number<br>
end if <br>
else<br>
'-q parameter not found...<br>
end if<br>
<br>
else<br>
'no arguments passed in<br>
'do default...<br>
end if <br>
<br>
end sub<br>
<br>
This is a pretty simple implementation. You probably want to check for other argument types in addition to the '-q'. You just have to get creative with a string parser. By the way, the VB6 documentation has an example of this.<br>
<br>
Hope it helps,<br>
-Motts
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.