How can run progress bar?! help

vb6 Bahrain
  • 14 years ago

    Hi...

    In my project (VB6) I have code is run in Command Prompt (DOS) and in the same time i want progress bar work with DOS then after finish work they must go to other form (form2)...

    but i dont know how can i connecting the statement to work with each other?

    please help me if any body have an idea...

    Regards

    bodoora

  • 14 years ago

    Hi Bodoora,

    What exactly you are doing in DOS.  Are you executing a Batch File or another EXE File.  If execute a exe file or batch file from VB it will run as a seperate process.  We cannot trace the status of that process.  We will get only the exit status of that process.

    One thing we can do you update the DOS process status to the database.  And from the database you can get the status.

    Any way tell me what exactly you are doing?

    Ch. V. Sudhakar

  • 14 years ago

    Hi Sudhakar...

    This is my code and there are some command in the code for what i want to do

    and where i want help... 

    Private Sub start_Click()
    Dim Apath As String

    'if no text loaded or no text typed
    If txtFileText.Text = "" Then
    MsgBox "Please Load a Text "
    'if the text is in textbox
    Else



    'first erase any text in the file
    Open "C:\buckwalter_morphan_1\data\infile.txt" For Output As #1

    'write the text that user want to tag in the file
    Print #1, txtFileText.Text
    Close #1

    '**these statement to open DOS**
    'open command prompt to run Perl script
    Open Apath & "dos.bat" For Output As #1
        Print #1, "cd C:\buckwalter_morphan_1\data"
        Print #1, "perl -w AraMorph.pl < infile.txt > outfile.txt"
         Close #1
          
        ' ShellAndWait Apath & "dos.bat"
        Shell Apath & "dos.bat"







    '**this is for run progress bar**
    ProgressBar1.Value = 1
    Timer1.Enabled = True

    '**How can we connect DOS and progress bar to work together
    '** in the same time then after finish there work move to form1?**
    Form1.Show


    End If

    Thanks for replay

    Regards

    Bodoora

  • 14 years ago

    Hi Bodoora,

    We cannot get the process status from that.  But one idea I can give you.

    Instead of progress bar put some animated image on you form.  And when ever your DOS process starts display that image to user and change mouse cursor to hour glass.  So that user will understand that some process is going on.  Or other wise put some text on you form that "Processing please wait...............".  Every body does the same when they cannot trace the process status. Smiley Face [:)]

    And to know whether that DOS process ended or not.  You follow this steps.

    1. At the end of your perl file you write some code which will create a empty file in c: drive with the name a.txt.  (So that if a.txt is available in c: drive then what it means is your perl process ended.)

    2. Activate timer on your form which will check for c:\a.txt.  The timer has to check whether this file is available in c: drive or not for every X seconds.  X is the number of seconds.  You can assign some value for it.  Put the below code in timer.

        If Dir("C:\a.txt") <> "" Then
             timer1.enabled =false
             'Means DOS process completed.  Write your code here
        End If


    3. Now make that animated image on you form invisible.  And display the form2.

    4.Remeber if you again run the same process first remove the a.txt from c: drive.

    In my opinion this is the best and easiest way for you.

    Hope this will help you.

    Ch. V. Sudhakar

  • 14 years ago

    Dear bodoora

    You can run the batch file silently and put the progress bar in your vb6 form
    or you can print dots with percentage like progress bar in your dos

    Regards
    DoctorMahdi

  • 14 years ago

    Hi Sudhakar..

    Thanks a lot,

    In my project in the timer i put the below statements and it now can run DOS and progress bar together but not always in the same time:

    Private Sub Timer1_Timer()
    ProgressBar1.Value = ProgressBar1.Value + 1
    If ProgressBar1.Value >= 100 Then
    Timer1.Enabled = False
    Form1.Show
    End If
    End Sub





    So if we went to use change mouse cursor to hour glass.. How can we do that?

    Regards

    Bodoora

  • 14 years ago
      Form1.MousePointer = vbHourglass
      or
      Form1.MousePointer = 11

  • 14 years ago

    Hi DoctorMahdi..

    Thanks for replay..

    Can you describe to me how can we use that change mouse cursor statment in my code above?

    Thanks

    Regards

    Bodoora

  • 14 years ago

    Hi Bodoora,

    Private Sub Timer1_Timer()
       ProgressBar1.Value = ProgressBar1.Value + 1
       If ProgressBar1.Value >= 100 Then
          Timer1.Enabled = False
          Form1.Show
       End If
    End Sub





    If this is the code you are using....... then its wrong.  You don't know whether the DOS process ended or not.  After counting 100 its going to show the form1.  Some times by that time DOS process may not end.

    Better use the option I suggested above in my previous reply. 

    Ch. V. Sudhakar.

  • 14 years ago

    Hi Sudhakar...

    I know is the code is not good because i do many testing for many texts small and big, So Iam now change the value from 100 to 200, until now its ok the DOS can finish run befor the progress bar move to the next form, but may be i have same problem in futur.

    So if the change mouse cursor to hour glass can help me in this program...

    please, describe to me the steps to do that..

    Thanks

    Bodoora

     

  • 14 years ago

    Hi Bodoora,

    Changing Mouse cursor is not going to do any thing.  Just I said if you change the mouse cursor to hour glass then user can understand that some processing is happenning.  Later once your process ends you change the mouse cursor to normal.  Thats it.  Its just an indication for the user that some process is happenning internally.

    When your process starts use this code to change the mouse cursor to hour glass.

    me.mousepointer=11 'changes the mouse pointer to hour glass

    once your process ends change cursor to normal

    me.mousepointer=0  'changes the mouse pointer to default pointer.

    Hope this will help you.

    Ch. V. Sudhakar

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The generation of random numbers is too important to be left to chance.” - Robert R. Coveyou