Results 1 to 7 of 7

Thread: vb6 is their a code for pause , while its pausing other task should run as normal.

  1. #1

    Thread Starter
    Banned
    Join Date
    Jun 2017
    Posts
    116

    vb6 is their a code for pause , while its pausing other task should run as normal.

    i had a code like this cant find it.

    pause 1 or

    pause 5 and while its paused to test it let a label count up or down this way you know the pause execution is running and the counter is going up or down.
    this way u can work beter.


    normal pause codes while it executes when u drag form it stops the count down or other stuff when u let go off mouse the pause resumes

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: vb6 is their a code for pause , while its pausing other task should run as normal

    You can pause a timer.

    Not sure what you are really trying to ask.

  3. #3

    Thread Starter
    Banned
    Join Date
    Jun 2017
    Posts
    116

    Re: vb6 is their a code for pause , while its pausing other task should run as normal

    add a pause code

    add 1 timer = 1000
    in timer add label1.caption =label1.caption +1


    on button click
    timer1.enable=true

    button 2 click
    pause 5
    msgbox "blaa"

    after you click button one , click button 2 and se if the labels still count or hang till the pause is finished.
    what we want is the timer to count on regardless even if other code is executing

  4. #4
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Re: vb6 is their a code for pause , while its pausing other task should run as normal

    I've got no idea if this is what you're talking about ...

    Code:
    
    Public Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
    
    Calling that will "pause" your entire program for the specified time, while letting everything else in Windows to keep executing. Just understand that nothing in your particular program will execute for the specified "Sleep" time.

    EDIT1: You use it by just saying something like Sleep 5000 to sleep for 5 seconds.

    EDIT2: In technical terms, Windows will "Sleep" your program's thread for the specified amount of time.

    EDIT3: The only other thing I could think of is something like the following...
    Code:
    
    Public Sub Pause(Seconds As Long)
        Dim start As Single
        start = Timer
        Do
            If Abs(Timer - start) > Seconds Then Exit Sub
            DoEvents
        Loop
    End Sub
    
    DoEvents is highly discouraged, but that's the only way you're going to get a pause that lets other aspects of your program to run while doing the pause. Also, I did the Abs() to handle the case where the pause eclipses midnight.
    Last edited by Elroy; Aug 29th, 2017 at 04:56 PM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  5. #5
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,048

    Re: vb6 is their a code for pause , while its pausing other task should run as normal

    Hi,

    this is more or less what Elroy posted, except I use the date

    you will need a Timer and a Label
    Code:
    Option Explicit
    
    Private NextCheck As Date
    Private CheckIntervall As Long
    Private Sub Form_Load()
          NextCheck = Now
          CheckIntervall = 5
          CheckIntervall = 25
          Timer1.Interval = 200
    End Sub
    Private Sub Timer1_Timer()
       Dim s As String, s1 As String, s2 As String
          DoEvents
          s2 = "Log: next Check in "
          If NextCheck > Now Then
             s = Format(NextCheck - Now, "nn:ss")
             If s <> s1 Then
                Label1.Caption = s2 & s
             End If
             s1 = s
             Exit Sub
          End If
          Timer1.Enabled = False
          Label1.Caption = "Check läuft ..."
    MsgBox "times up!"
          'your action here
          NextCheck = DateAdd("s", CheckIntervall, Now)
          Timer1.Enabled = True
    End Sub
    regards
    Chris
    to hunt a species to extinction is not logical !
    since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.

  6. #6
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: vb6 is their a code for pause , while its pausing other task should run as normal

    IMO if you need to insert a pause that will allow other code to execute and wait before the current code continues then it is a matter of poor program flow and the best solution is to redesign the way your program works.

  7. #7
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,936

    Re: vb6 is their a code for pause , while its pausing other task should run as normal

    Truth be told, I wholeheartedly agree with DataMiser. Unless it's some kind of game, where you want a pause for some kind of effect, I see little reason for a pause. It's typically just a waste of time.

    However, there is one other place I use a pause in my main application. It's where I'm quasi-automating another third-party application. There's no "true" automation ability, so I have to do it the "hard way". I automate it through an API version of SendKeys. However, it's sometimes a bit slow in responding to the keystrokes, so I put small pauses (sleeps) in my code, giving it time to process. I'll admit that it's a bit of a kluge to do this, and that I should possibly monitor (i.e., spy) on the other program to see if it has responded before sending the next keystrokes. However, it's been working for years, and I see no compelling reason to change it.

    I also suspect this may be why gennna21, is doing it. With all of her posts, they've yet to outline what they're doing, other than it has something to do with internet exploring. It wouldn't surprise me at all if they're up to something nefarious. However, it doesn't appear that they have the skills or knowledge to really do much damage.

    Best Regards to All,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

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