Results 1 to 2 of 2

Thread: An easy and interesting question

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    brooklyn
    Posts
    48

    Post

    Basically I try to use the shell command to
    sort a simple text file and generate another file.

    My visual basic code is following:

    Private sub Command1_click( )
    Dim strCommand as string
    Dim sngMark as single

    StrCommand=app.path & “\sortSum.bat”

    Shell strCommand, vbMinimizedNoFocus

    SngMark=timer
    Do
    DoEvents
    Loop until timer-sngMark>2
    End sub

    The batch file sortSum.bat is following:
    C:\winnt\system32\sort <c:\somefile> c:\outputFile
    (or sort <c:\somefile> c:\outputFile)

    somefile is just a simple text file I want to be sorted.

    The problem is that there is no outputfile be generated after
    Execute the VB program. But if I execute the batch file (sortsum.bat) in the
    Dos system, there is outputfile being generated.

    does anybody know why? I have been burdened
    with this problem for several days and I ate very little because of this; Please heellp.

    Thanks a lot.

  2. #2
    Hyperactive Member Al Smith's Avatar
    Join Date
    May 1999
    Location
    Marcellus, MI. USA
    Posts
    330

    Post

    Hi,
    Your shelled program is not finished before VB continues.

    The first question I asked on this excellent site was "How can you tell when a shelled program has finished?".

    The answer is below:

    http://www.vbsquare.com/tips/tip280.html
    Al.


    ------------------
    A computer is a tool, not a toy.
    <A HREF="mailto:[email protected]
    [email protected]">[email protected]
    [email protected]</A>


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