Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Make A Program Sleep!!!

Is there any short and simple way to make a program sleep for 2 seconds??? I have a program that is openening a window and entering text, but the window takes up much memory and it can't open fast enough for the program... So I need the program to wait 2 seconds for the window to open.

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Make My Program Sleep ?

I m starting a shell command that needs about 5 seconds to be run properly.
I want the next instruction in my program to be run 5 seconds after the shell instruction.

I cannot find a wait or sleep function in VB6, how could I do?

thnaks a lot

Can Not Make Program "sleep" For A Few Seconds
i think i found some kind of weird bug. i need a label to display something, and change after a few seconds. im trying to use the Sleep() API function which is very simple and straigh forward. check this out.... as an example lets say i have this


Label1.Caption = "im awake"
Label1.Caption = "im asleep"

End Sub

or something just as simple. "im awake" should be displayed, and after 5 seconds it should change to "im asleep".
the problem is that the Sleep function seems to fire BEFORE the first line of code. its very weird. can anyone help out with this?
when you click the button nothing happens (the label SHOULD change), after 5 seconds, it displays "im asleep"
anyone? someone??

How To Make An App Sleep In 1 HOUR
hi all,
how can I make my application can SLEEP in 1 HOUR ?
thanx all

Make App Run While PC Is In Sleep Mode
How can I make my app continue working even when the computer is locked or in sleep mode? Like it has a timer and does functions at certain times of the day, so can I make it still be doing things while the pc is in sleep or locked?

Make The Application Go To Sleep
Hi !

I know that exist some API which cause the application to sleep , but also affect on the computer and slow it down.

Is there any other API (and only API , I know that i can use the timer as well), which supply the same service, but without any side affects.

thx !

How Can My Program Sleep
Hi List

I ask a question, how can I stop a program for some seconds in the General Discussion List.

I get the follow answer

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Sleep 2000

Now I have a problem.

Always when I insert this String the VBA Editor take the line like a normal Command line

Normally Code looks like this

Privat Sub
End Sub
Privat Sub
End Sub

If I put in this Line I get not

Privat Sub
End Sub
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Privat Sub
End Sub

but this one

Privat Sub
End Sub
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Privat Sub
End Sub

an so I get always an Error like "After END SUB there can be only Comments"

Any Idee?


Get A Function To Sleep, Not Whole Program
First off, sorry if this is in wrong board, I didn't know where to put it. Anyways, I'm writing a program that streams video to a shoutcast server. I have it do it by sending a little bit, sleeping for a tenth of a second, then sending a little more, and it continues this. Doing just this, it works fine.

I'm trying to add other things to my program, which also involve doing things at a certain timing, but the Sleeps are interfering with each other.

I have each part broken into a function. Is there anyway that I can get just the function to pause and allowing other parts of the program to continues as usual? A little searching brought me to SleepEx, but it either is the wrong thing or I'm not using it right, as it does the same thing as Sleep.


Exiting A Program Using The Sleep API

I have the sleep statement in an loop that I want to break out of if the user wishes to close the application.

Sort of:

Check status
Exit program if user wishes

Check Status
Exit program if user wishes

As I have it now it just checks and goes to sleep and the app does not allow exit.



How To Start Program After SLEEP
I'm using the following code to make my program sleep for x amount of time

If CountSleep = 25 Then
txtMain.Text = "Sleeping Now Wait 15 Minutes"
CountSleep = 0
Sleep 1500000

After the Sleep timer reaches the 1500000 (is it even 15 minutes?) how do I get the program to start up again?

Problem In Using Sleep Function In My Program
hi all,

i had 8 set of pic. one appear after another. initially, my program is as follows:

Delay 1
Picture2.Left = Picture2.Left + f * 1 / 8
Picture3.Visible = False
Picture4.Visible = False
Picture5.Visible = False
Picture6.Visible = False
Picture7.Visible = False
Picture8.Visible = False
Picture9.Visible = False

Delay 1

Picture2.Visible = False
Picture3.Visible = True
Picture3.Left = Picture3.Left + f * 2 / 8

Public Sub Delay(HowLong As Integer)
TempTime = DateAdd("s", HowLong, Now)
While TempTime > Now
DoEvents 'Allows windows to handle other stuff
End Sub

i find that the delay is too slow and i change it to sleep function and i get the result as attached. what should i do to solve the problem? thanks.

[VB6] Sleep Command Freezing Program
For some reason, my program freezes during the looping of the multiple TAB keysends. Sleep is declared privately.

Private Sub cmdStart_Click()
Dim time As Single
Dim key As String


key = txtKey.Text
time = Val(txtSecond.Text) * 1000

MsgBox "Started"

Select Case Len(key)
Case Is > 1
key = "{" + key + "}"
End Select

Do Until hello = True
SendKeys "{TAB}"
Sleep 5000

MsgBox "Stopped"
End Sub
Also, I was trying to activate a button by doing "Call button" if the key "~" is pressed. Key preview is on, it just isn't working for some reason.

Private Sub frmMacro_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case 96, 126
Call cmdStop_Click
End Select
End Sub
Any advice?

[sloved]need Help Putting My Program To Sleep
I want to pause in between "WebBrowser1.Document.getElementById("previewForm").Click" and "WebBrowser1.Document.getElementById("finishForm").Click" so the web page can load but the sleep command is putting the hole thing to sleep be before it starts?

Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)

Private Sub Command1_Click()
WebBrowser1.Document.getElementById("PostingTitle").Value = Text2
WebBrowser1.Document.getElementById("PostingBody").Value = Text1
WebBrowser1.Document.getElementById("FromEMail").Value = Text3

Sleep (5000)


Program Wont Work With Sleep()
I have this app that kills a file thats been copyied to the desktop, it reads the path of the file fom text.txt then kills myapp.exe, only problem is that it only work if i have the msgbx before kill "" etc.. i have tried a sleep but that doesnt work, get file access error, i'm thinking you need a delay there because it takes a bit of time to read in the file then send it to step1 etc... but a msgbox is no use for me. Well this maybe be tricky to understand but any suggestions would be geat.

Open "F:Documents and SettingsmineDesktop ext.txt" For Input As #1
Input #1, step1
Close #1

MsgBox "FINE"

Kill "" & step1 & "myapp.exe"

Creating Delay With Sleep... In A Loop Causes Program To Freeze For A While
Hello, thanks for the advice to use Sleep function instead of DoEvents() in order to create a delay, this did not cause a 99-100% CPU usage.

But anyway, some problems ahead. I need to have this sleep function in a For loop, which causes the program to go into a "not responding" state for a while until recovery..

I would need the sleep function to be called in a loop like this

Sub SendingValues()

For x = 0 to 15

'here I open com port send values and close com port

Sleep 1000


well as i said before this freezes the program for a while. stopping the for loop on the middle with msgbox for instance the loop with the sleep function works as it should

How Can I Make A Program That Will Make It So That Windows Recognises A File-type?
can any1 help? i am making a program which uses *.pli files, and i want my system to recognise them instead of showing them up with the white icon with the windows system. I no i can do it by going into the folder options (I have windows 98 btw) but can u get vb to do it 4 u in a program? (This program is going to be distributed among lots of people who all use windows, but not necessarily windows 98, i dunno if that makes any diff.)

How To Make A Program Shareware And Make Provisions For Registering It With A Key
i wish to make my program shareware.
how do i program for provisioning for the registering by a key, till that the program should display a message saying it is unregistered?
the key should be unique for all the customers.

How Do I Make My Program Make Text Files And Save Them?
I need to be able to save text files to file and access them later without using common dialogs, any code?

How Do I Make My Program Make A Back Up Of The Registry?
How to I make my program to make a back up of the registry under the name I want it and in a folder I ask for it to go to??

for ex. You click on a button and it starts making a back up of the registry.

Thanks for your help again.

How To Make A Program That Will Check If The Latest Program Is Update To Date?
How to make a program that will check if the latest program is update to date?

lets say the program got revison 1.0.0, revision 1.0.1 ...
when a user start a program, it will download the latest program the the latest program will be started.


How Can I Make My Program Read The Cursors Location And Stuff Outside Of Program...
Okay, the subject mainly says it all:
How do I find the cursors location and other things outside of the program window.

Thank you,

Program Freezes While Using "Sleep"
intSeconds = (hours * 3600) + (minutes * 60) + seconds
timeLeft = intSeconds

For seconds = 0 to intSeconds
timeLeft = timeLeft - 1
Sleep 1000
Next seconds

When I run my program and hit the button that is supposed to count down the seconds, it just freezes and I have to end task VB. Any help appreciated, or another way to make a counter. Thank you.

Sleep Little Thread, Sleep
Hi out there.

I'm getting stupid! I created a new thread. The thread calls a function which sets a textbox on a form to current time. Works well but my cpu is running 100%. No question cause there is a do ... loop with text1 = time$ inside. Going forward i inserted a sleep(500) into the loop. Guess what happened? The app crashed. Now tell my why. I tried everything. Any ideas?

Public Function threadDO()
Sleep 500
Form1.text1 = time$
End Function



Make Window In VB But Make Program In C/C++?

I heard a roomer that yoyu can have the nice and easy way of creating a window and buttons with VB but make the core of the program in C/C++. Is this true..and if so I'm very intrested in learning how...because making windows in C++ for quick programs is very time consuming

thanx in advance,

How To Make My VB Program Into An Executable Program
I have this problem that whenever I activate the Make exe command under file menu. The computer will start compiling but before completing it the system will display an error message like this one "THERE IS NOT ENOUGH SYSTEM RESOURCES AVAILABLE TO RUN THIS PROGRAM" then the system will hang.

It started acting like this almost a week ago when my pc was infected by a virus. I have the entire hard disk formatted using fdisk and installed it everything back but this time it wont compile my programs. This is the first time I encounter such a problem. Is there anybody who could advise me on how to solve this problem?

Need Help To Make My Program A 30 Day Trial Program
Need help to make my program a 30 day trial program

Need Help To Make My Program A 30 Day Trial Program
Need help to make my program a 30 day trial program

Need Help : Want To Make My Program Look Like XP
I Want To Make My Application Look Like Windows XP Interface
I Tried The ("applicationname".exe.manifest) But It Didnt Work So Can Anyone Give Me The Code Or A File That Does This Operation
Thank You

I Will Appreciate Any Help From AnyOne

Answer Me As Fast As You Can

Can't Make Program End
I have an Exit option in the File menu which works perfectly.
This is the code for it. But when I click the X button on the main form it does not exit. It doesn't even close the main form. I have no idea what's wrong.
Here is the relevant code.

Private Sub mnuExit_Click()
End Sub

Private Sub Form_Terminate()
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
'As soon as you unload the main form make sure you unload
'any other forms which have been opened
Dim frm As Form
For Each frm In Forms
Unload frm
Next frm
End Sub

Private Sub Form_Unload(Cancel As Integer)
Dim dummy$
Dim retval

'Make sure that the help file closes when you exit the program
retval = WinHelp(hWnd, dummy$, HELP_QUIT, 0)

'As soon as you unload the main form make sure you unload
'any other forms which have been opened
Dim frm As Form
For Each frm In Forms
Unload frm
Next frm
End Sub

I Want To Make A Program That...
...Lets you test html and javascripts, any idea on how I would do that?

Program Make
i need code to get my "program make" otherwise known as the program "Version". i would like to get it without opening the program if possible. but i also need it when the program is open.

i assume i need to use the API.

Make Program Run Once?
Is it possible to make a program only once and then the user can never use the program again? Even if s/he sends it to someone else it cant be used?

Trying To Make Program For Fun
I'm Trying To Make Something That Calculates LEtters IN VB6

I Have This But It Doesnt Work

VB Code:
Private Sub Command1_Click()a = 1b = 2c = 3d = 4e = 5f = 6g = 7h = 8i = 9j = 10Label1.Caption = Text1.Text + Text2.TextEnd Sub

Need Help For VB6


Make Program Always On Top.
Very strait forward. How do I do it?

How Can I Make A Program Do...
how can i make a program type a character on a different window? for example i want my program to type a when i push start, but all it does is type a on the same window, i want it to type on the active window.

Make Program Always On Top
hello everybody

does anybody know how to make program on top with a code to enable or disable this property

i had one but i lost it

thank u for ur ccoperation


Make Exe Using Program

Is there a way to make a program that will make other programs. In other words i wish to make a program like VB so i can let users customize their file by changing icons, code ect. Any help would be appriciated.

Thanks in advance

Is It Possible To Make This Program Using VB?

The link above is to a some flash of software that designs Football plays. I wanted to know if a similar version is possible in vb?

Help ... How Can Make This Program
how can make program with vb
using this alogarithm
subsets of a set

three algorithms are described to answer the problem how to generate all the subsets of a finite set

algorithm : to generate all the subsets of a finite set.

input: a set a{x1,x2,...,xn}
output: all the subsets of s

the idea behind the algorith is ti construct a characteristis function to identify the elements of s for each subset. if s has n elements , the binary strtings with n digits serve the purpose. for a given binary string , each digit corresponds to an x in s. if the digit is 1 then include x in the subset; if the digit is 0 then exclude x .

method : m <--- 0

while m < 2^n :

express m as a binary string of length n
(m=a1 2^n + a2 2n^n-1 + ... + an 2^0)
define the characteristic function
( ci <--- ai for i=1,2,...,n)
choose the subset y correspnding to m
(if ci = 1 then include xi in y)
record y (print or store in a file)
m <--- m+1

Example 1 : find all the subset of s ={a,b,c} using algorith

method : if the set s is empty , then fiy is the only subset of s ; record fiy

otherwise select arbitraily an element x ( s
find all the subsets of s - {X} and
for each subset y of s={x} , record {x} U y .

the idea behind this algorith is to use a recursive aproach . the statment find all the subset of (s-{X}) invoves a recursive call. the sets s,s-{x} , ... form a strictly decreasing sequence , for each set is a proper subset of the noe befor. the sequence must end with the empty set , fiy , since s is finite
hence the recursion will terminate

Need Some Help With A Program I Need To Make
I need to know how to,

1. Rename files then run a program and when the program closes change them back to there original name.
2. Get the path from the registry to run the program

Any ideas?

How To Make This Program?
I wonder if there is a program which can read specific path of Windows Registry.

How To Make This Program
I want to make a simple and small program.
In this program,it has one TextBox(multiline is true),one Label,one Command button.,
What I want is that when I type something in the textbox,then Click the command button,it will shows "what you type+http"
in that label each line.

for example:
I type

click the command button,

so the Label shows: http http

so how can I do that?
Thanks a lot.

How Can You Make Your Program......
How can you make your program paste itself in a certain place, without the user knowing

How Do I Make My Program :
do you have a link to some script ???
i basically have very little about VB except what i am using
so yeah ??????
and how do i use the alt+0169 thing in a label ????

How To Make A Dos Like Program
how can i make a text based dos like program with a textbox?

say i want to do the following:

press "ctrl M" and then "ctrl spacebar(acting like an enter key event)" to bring up a menu

and stuff like that, but it all has to be textbased, and it has to be like dos, or Q basic if you will

thanks in advance

How To Make Dos Like Program
How can i make a program that will have a black backround and you type commands in and get responses back, i want to be able to make alot of commands for it though.

How Can I Make My Program To Be ALWAYS ON TOP?
I want to have a program to be always on top , as the subject says
any idea how I can do it?

How To Make Program Always On Top
how do you make a VB program be like one of those always stay on top?


How Do You Make A Program A .exe?
Is there some special program to make a vb program into a .exe?

Copyright 2005-08, All rights reserved