General discussion

Locked

Shell Function in VB6

By paespi0 ·
Hey. I'm updating a QBasic program to VB6. I'm trying to update a certain piece of code that works fine in Qbasic, but isn't working correctly in VB6. Here is the code written in Qbasic:
"Shell sort /+1 < c:\pb\wrk\mac.wrk > c:\pb\wrk\mac.srt"
in VB6:
RetVal = Shell("sort /+1 < p:\pb\wrk\mac.wrk > p:\pb\wrk\mac.srt")

The mac.wrk file is created earlier in the program and all I want this piece to do is sort the file and place it in mac.srt. For some reason the mac.srt file isn't getting created in VB6 and the whole program fails. Can anyone help me?

This conversation is currently closed to new comments.

8 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Shell Function in VB6

by VinnyD In reply to Shell Function in VB6

There are a few reasons why it will not work.

1. It has to find the sort.exe program.

If sort.exe is not found it will not work.

2. Is the P: drive accessible?

if there is no p: drive it will not work

3. Does the p:\pb\wrk\mac.wrk whole path exist?

You can also try this:

RetVal = Shell("sort /+1 < p:\pb\wrk\mac.wrk > p:\pb\wrk\mac.srt", vbMaximizedFocus)

In VB this will maximize the DOS window so you can see the command execute. If you have a fast computer you maynot be able to see it.

Last

Put the command "sort /+1 < p:\pb\wrk\mac.wrk > p:\pb\wrk\mac.srt" in a batch file and try and see if it works from the DOS prompt.

What happens is any error at all and the command fails.

Collapse -

Shell Function in VB6

by Shanghai Sam In reply to Shell Function in VB6

1. It does find the sort program.
2. P drive does indeed exist
3. The 'p:\pb\wrk\mac.wrk' path exists
4. It does work from the dos prompt

Collapse -

Shell Function in VB6

by andrew In reply to Shell Function in VB6

The VB Shell is designed to run an executable file, not a set of statements.

Create a batch file (macsort.bat) that has the sinlge line

sort /+1 < p:\pb\wrk\mac.wrk > p:\pb\wrk\mac.srt

in it.

Call this with the shell:

retval = Shell("p:\pb\wrk\macsort.bat")

Collapse -

Shell Function in VB6

by andrew In reply to Shell Function in VB6

'Shell' is asynchronous.
Here's a link to an article about how to know when the batch file has finished:

http://support.microsoft.com/support/kb/articles/q129/7/96.asp

(make sure there are no spaces in the URL)

Collapse -

Shell Function in VB6

by paespi0 In reply to Shell Function in VB6

Poster rated this answer

Collapse -

Shell Function in VB6

by MagicDress In reply to Shell Function in VB6

hi paespi0,

the only problem i can see is the < > around your .wrk filename. it works fine from vb6 with .txt files.

hth,
becky

Collapse -

Shell Function in VB6

by Shanghai Sam In reply to Shell Function in VB6

I took the '< >' out and it still didn't work.

Collapse -

Shell Function in VB6

by paespi0 In reply to Shell Function in VB6

This question was closed by the author

Back to Web Development Forum
8 total posts (Page 1 of 1)  

Related Discussions

Related Forums