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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with %

Status
Not open for further replies.

vmaruv

Programmer
Apr 8, 2002
102
US
This board is awesome !! Thanks a ton to the moderators and all the others helping people like me.

I am new to VB and am executing a project.
In my VB code I am calling an external batch file using the shell command. It executes the file and returns the output in a text window. However, in my file I have a command

call %data%\vars

The execution of this unsuccessful because it is not able to resolve the % symbol. In the results text box i have seen that it is being executed as call data\vars with out the % symbol. Hence is throwing a message "the system cannot find the path specified"

Please can someone suggest a solution to this problem ?

Please help.

 
If you know what the path is, you could create the batch file from within your program and then run it.
Processing text files in VB is easy and can be very helpful in other ways.
Be aware that you must ensure that the file is created and closed prior to running it. Sometimes VB doesn't let a command finish before executing the next one (particularly true for data access).
Hope this helps.
 
Go to a command prompt and type in 'CALL /?' (without the quotes) to get the full syntax of the CALL command

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
%data% is probably an environment variable.

In VB, you can get the value of an environment variable by calling the Environ function.

Ex.

Msgbox Environ("path")

You will still have problems with the 5 symbols, though.

You can remove the percent symbols with the replace function. Ex. myVariable = replace(myVariable, '%', '')

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top