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




Making A Function Take Longer To Execute (sleep ?? ))


Hi
I need to make a function take longer to execute, but not by inserting loops and so, perhaps a function that delays the execution of instructions.
I need this because I need to use an object with php and php unloads the object just after the function returns anything.
Or perhaps I could return the value of a function from an other (very unlikely to me)?
Thanks!




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Execute Exe File While In Sleep Mode
I have developed a small program to download data from 2 databases and place in another database. My program must be interactive. My program resides in the win2k server, i noticed that when the server is locked and i logged again my program has terminated. I want my program to run continously. Like the SQL Server it is accessible even your pc is on sleep. Can anybody give me a solution for this thanks a lot.

Making A Form Longer
Quick question-hopefully warrants a quick answer...

I have a list of option buttons I need to add to a form, but the form is not long enough and will not let me make it any longer. How do I make it scroll similar to a webpage? I have about 30 options to go below some 18 text boxes.
Thanks in advance!
Greg

Making InputBox Longer?
Hi all,

Just a quick question - is it possible to force the size of inputbox to be longer, without having to make my own one as a form? To stop problems like this:



I tried changing the XPos and YPos, but that's just the position of the inputbox on the screen....

Thanks!

Making The Label Bigger When Text Is Longer
Hi

I want to know if it is possible to have a lable that get bigger when you enter more text in it. Autosize is for the lenght but my problem is that the caption get off the screen so I would like to have a label that will add height when necessary instead of lenght.

Thanx in advance

bibiteinfo

The Left$ Function No Longer Works
Help, the Left$ no longer works in my module. I get an "Type Declaration Character does not match declared data type". If I remove the $, it thinks it's an undeclared variable. Any Suggestions? This module has run correctly before.

Can I Use Sleep API Function In Thread Function
Hi all

i am trying to use sleep API function within the body of the thread functio, but i can't an error occur

for example

Private Sub Command1_Click()
hThread1 = CreateThread(ByVal 0&, ByVal 0&, AddressOf th1, ByVal 0&, ByVal 0&, hThreadID1)
End Sub

Public Sub th1()
While (True)
Form1.Label1.Caption = Val(Form1.Label1.Caption) + 1
Sleep(1000) ' the error occur when sleep function end
Wend
End Sub

also u must note that when i run the program from the VB its work probably, but when i make an EXE file and run it ... the errors occur

the error messege is:
The instruction at "0x6aaa7339" referenced memory at "0x0000009c". The memory could not be "written".
...

About The Sleep Function
Hi, I don't know how to work the sleep function, is it something I have to define, or is it an API, I'm lost, if someone could please help, thanks

Sleep Function?
Is there a sleep function (or timer) in VB? Our program is working too fast!

Thanks!

Sleep Function
Hey dear kind people reading this...

HELP!!!
I want to have a delay in my program
But it won't work with a timer
So, I know I need to use the sleep function
But I don't know how
Could someone please help with the code, and explain what's going on if possible
Thanks so much!!!

Sleep Function
Hi,
I am using the Sleep function from win32 lib and my application
freeze.

Obviously because it is used in a loop and I set the time
to 1 millisecond. In the same loop I call DoEvent Function.

The application uses the vbModless in order to show the
window in the taskbar.

The usage of this Mode and the Sleep event is because
the application is using 100% of the CPU

Any help here?

Thank you
Ziko

What Does 'sleep' Function Do?
With reference to my previous thread on copying USB drive



http://www.vbforums.com/showthread.php?t=503894


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


I was told that the 'sleep' function pauses the application for specified time interval. (May not necessarily give time to other processes to run simultaneously ).

Is it true?


So what is the difference between 'sleep' and this loop?


Code:
Dim date1 As Date
date1 = Now
While (DateDiff("s", date1, Now) < 5)
Wend



My main concern is to let my application give some breathing time to other processes while copying folders of several gig in size

Sleep Function In OCX
If i use the sleep function in an OCX will it effect the program that it is using, or will it just make the OCX sleep/

?

ILMV

Sleep Function
Does anyone know how to make a sleep function, I want to make a picture visible, then wait 1/2 a second then make it visible and so on and so on

Thanks

Is There A Sleep Function In Vb?
is there a sleep function in vb? where I can stop my code from running for about 5 seconds to wait for something else to finish.

this is from vb help, I need to wait for my batch file to finish before my code continues. I'm surprised there isn't a wait or sleep function, what am I missing?
Note By default, the Shell function runs other programs asynchronously. This means that a program started with Shell might not finish executing before the statements following the Shell function are executed.

Sleep Function?
is there a way to let the computer wait a little while ( i've got vb 6, learning edition)

in qbasic (yeah, i did a little of that too ) it was just " sleep 1 " or something like that...

How To Use Sleep Function In VB??
Hi
How to use Sleep Function In VB?? Any help on this?
thanks in advance
Karthik K

Sleep Function
does VB5/6 contain something like a 'sleep' function ? say i attempt to contact a remote server but at the time no connection can be made, and i'd like the code to try again after a wait of 15 minutes

i'm currently sending the errortrap to a timer with an interval of 60000 milliseconds where it loops 15 times, but that seems a rather clumsy way of doing things

Sleep Function ...
Hi Patrick,

Please you can give me an example of a sleep function ?

Thanks in advance
Abilio

Help Using The Sleep Function In VB6
HI All

Wonder if anyone can help. I am using the sleep function, but not sure why I am getting the follwoing error:

Compile Error: Sub or function not defined?

My code is:

Private Sub Form_Load()
Dim Counter As Integer

Call AddToTray(Me.Icon, Me.Caption, Me)

Counter = Counter + 1
Text1.Text = Counter

Sleep 2000

If Counter = 30 Then
Call StockUpdate
Counter = 0
End If

End Sub

Kindest Regards

Peter email@removed

Sleep Function
Hi,

I wanna make my program do nothing for 45 min. because my program should wait for another program to finish and it takes the other program about 45 min to be done.

Should i use CODEPrivate Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Is Sleep Function Bad?
Hey there,
I was doing some reading on the sleep function, and some ppl seem to say it's not a good thing to use. I have a program that will load at the system startup, and i have Sleep set for 300 milliseconds. Is this ok?

Is There A Function Better Than API SLEEP?
I have read that from the internet that API sleep minimum delay is 10ms even though it is "sleep 1".

Is there a function that is almost like the API sleep but much more precise? Real 1millisecond delay?

I have seen some multimedia timer that is able to set the interval to 1ms and it really does. But I really need SLEEP function to do the job.

Thank you.

Sleep Function
When I use the sleep function like this:

WebBrowser1.Navigate "http://www.yahoo.com/index.html"
Sleep (5000)
WebBrowser1.Navigate "http://www.pcmarketfanatics.com/index.cfm"

It throws me an error like this:
"Compile Error: Sub or Function not defined"

Thanks,
Ben

Sleep Function Problem
Hey guys, nice to be here.

Can you please point out why this code doesnt work?

Private Sub Start_Button_Click()

Message_Box.Cls
Message_Box.FontSize = 12
Message_Box.ForeColor = vbBlue
Message_Box.Print "Wait for 10 seconds"
Sleep (10000) ' 10 seconds
Message_Box.Print "10 seconds have passed. Now you can continue"

End Sub

i'm aware that Sleep freezes the whole application but shouldnt it display the first message, then sleep for 10 seconds, and then display the second message? Because as soon as i hit the Start button, the program freezes without displaying the first message.

Any advice on how to make this work?


thanks in advance

Foundas

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.

TIA

Question About Sleep Function
i tried to use the vb sleep function described here , but i get the following error:
"Member already exists in a object module from which this object module derives"

here is my source:

Code:
Option Explicit
Private Declare Sub sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

Private Sub Command1_Click()
Dim User As String, Pass As String, PTries As Integer, UTries As Integer, tmp As String, Tries As Integer
Close #2
Open PList For Input As #2
Line Input #2, tmp
Line Input #2, tmp
Close #1
Open UList For Input As #1
Line Input #1, tmp
Line Input #1, tmp

For UTries = 0 To txtULines - 1
Line Input #1, User
CurrentUser = User
For PTries = 0 To txtPLines - 1
Line Input #2, Pass
CurrentPass = Pass
Inet1.Execute "http://" & Text1, "POST", Text4 & CurrentUser & Text2 & CurrentPass & Text3, "Referer: " & Text5 & vbCrLf & "Content-Type: application/x-www-form-urlencoded" & vbCrLf & "Accept-Language: en-us" & vbCrLf & "Accept-Encoding: gzip, deflate" & vbCrLf & "User-Agent: Mozilla/4.0 (compatiable; MSIE 6.0; Windows NT 5.1; yie6; .NET CLR 1.0.3705)"
lstData.AddItem (User & ":" & Pass)
Tries = Tries + 1
txtTries = Tries
sleep (sleep)
Next PTries
Close #2
Open PList For Input As #2
Line Input #2, tmp
Line Input #2, tmp
Next UTries
End Sub

Private Sub Command2_Click()
Dim UserLines As String, UTitle As String
CommonDialog1.Action = 1
UList = CommonDialog1.FileName
Open UList For Input As #1
Line Input #1, UTitle
Line Input #1, UserLines
txtUTitle = UTitle
txtULines = UserLines
End Sub

Private Sub Command3_Click()
Dim PassLines As String, PTitle As String
CommonDialog2.Action = 1
PList = CommonDialog2.FileName
Open PList For Input As #2
Line Input #2, PTitle
Line Input #2, PassLines
txtPTitle = PTitle
txtPLines = PassLines
End Sub

Private Sub Command4_Click()
Form2.Show
End Sub

Private Sub Form_Load()
On Error GoTo Err_Form_Load
CommonDialog1.InitDir = App.Path
CommonDialog1.Filter = "All Files (*.*)|*.*"
CommonDialog1.Flags = &H4&
CommonDialog2.InitDir = App.Path
CommonDialog2.Filter = "All Files (*.*)|*.*"
CommonDialog2.Flags = &H4&
Err_Form_Load:
End Sub
thx in advance
-Skeetch

Sleep Function Not Working Too Well
Hello, sleep is causing my system to freeze under the following circumstances
whereas sleep is defined as coming from the kernel32 dll

for i = 0 to 19
sleep 1000
msgbox i & " seconds have passed"
if i = 19 then
msgbox "time is up"
end if
next i

please keep in mind that i do not want to use the timer control for pausing the 1 second - i want to use sleep. any ideas? please respond to my email

jstic04@cp.centennialcollege.ca

Sleep Function In A Module?
Hi everyone,
I'm trying to write a function that uses the "Sleep" command, but when I call the function VB crashes (it stops responding)! My code looks like this:


Code:
Option Explicit

Declare Function Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Function Test()

Dim a As Integer

For a = 0 To 10
Sleep 1000
MsgBox ""
Next a

End Function


Please help me anyone!

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
Wend
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.

Pause, Wait, Or Sleep Function?
Does anyone know of a function that works in VB for apps (Excel) that provides a simple one-line way to wait for a couple of seconds? The only one I can find is the application.wait method which is awkward because it uses absolute time instead of just like wait 2 seconds.

Can I Use 'sleep' Function By Kernel On Other Processes, And Not My App?
hello,

can I use 'sleep' function by kernel on other processes, and not my app?
so that they will sleep and be on hold?

thanks

Sleep Function Tthat Allows Events ?
I know about sleep , but there is better sleep function i thikn its sleepex, anybody got an example ?

What Is Equivalent Function Of C++ Delay()/sleep() In VB
hi

    in C++ we have two functions sleep and delay. which will stops or waits for some time .

in vb also i want same things , how can i have like this.

thanks
---------------------------------------------
Srinivas.

Threading Fails With Sleep Function In
the module that has the code.

Gurus,
Here is the situation, I have the following code in module. I have a form that has a button. On clicking this button, i create a thread using createthread() api to execute the thread. when I am in IDE/Debug mode, the program does not give an error. But when I make it an exe and run the exe, the program aborts with "The instruction at 'xxxxxxxxxxxxxx' referenced memory at '0x0000009c'. the memory could not be 'written'.

But when I comment the sleep statement , the make an exe and run the exe, it works fine.

Is there anyway to solve this issue.

Thanks, I appreciate your help

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

and try to multi-thread the following function, I get an access violation.

Public Function addtext()

i = 0
'Do

While i = 0
Sleep (1)
If i > 0 Then
Form1.Text1.SelText = "i > 0 "
End If
Form1.Text1.SelText = "adding to textbox "
Wend
'Loop

End Function
</b>

Making Files Execute
I have created slide shows that are executable files to distribute to relatives - there are 8 shows - I want to have a menu page where they can just press a button to start a show - I have created a file that has the buttons etc. it is ready to go except i have not been able to figure out how to make the files open when i press the button - I alway get some kind of errors. These files will be on a cd - if that makes any difference and I will create an autostart file to run this application.
This is probably a very simple thing for you all - but I am new to VB

Making A Program Execute When....
how can I set with vbcode a program that starts each time the computer turns on? I dont want to do it with the schedule task thing!

Lookin For A Sleep Function Or Some Type Of Delay Which Doesn&#039;t Use System Resources.
Hey there guru's is anyone aware of a sleep/delay function that will not use system resources like a timer will.


Thank ya all in advance.

Function Name During Execute
My program uses a common error handling function. It's easy to get the error, make that exception, at execute time for display.

Is there a way to get the name of the function in which you are currently executing????? Better yet is the call stack available to get the called function names????

Execute A Function From A DLL
Hi,
I've got a prog in which DLLs are loaded. The names of the DLLs are unknown at Designtime but the signature and names of the functions which should be called are known. In my code i load the DLL that way:

handle = LoadLibrary("kernel32.dll")




Then i catch the address of my function

add = GetProcAddress(handle, "Function")




Now its the problem how can i call the function? The MSDN says something with CallWindowProc but each of the functions I'm using hast more then 2 Parameters.

I'm thankfull of every hint

akademos

Shell Execute Function
I need to know the entire code and syntax for using the x copy command in a Shell Execute function, that includes all arguments and parameters. I'm wanting to copy all the contents of a: to another specified directory on c:, including all files folders and sub folders. I have never used the Shell Execute function before.

Can someone please help me?

Execute Function In Opened .exe.
Execute function in opened .exe.

Hi,

I have a problem;

the first time i call i wanted to call form A and the second time I wanted to call form B. Currently I have these two froms in two different exe. So now is the question ...

Is it possible to open these two forms in the same exe?

thanks

Execute Function In Opened Exe
Execute function in opened .exe.

Hi,

I have a problem;

the first time i call i wanted to call form A and the second time I wanted to call form B. Currently I have these two froms in two different exe. So now is the question ...

Is it possible to open these two forms in the same exe?

thanks

Execute Function In Opened .exe.
Execute function in opened .exe.

Hi,

I have a problem;

the first time i call i wanted to call form A and the second time I wanted to call form B. Currently I have these two froms in two different exe. So now is the question ...

Is it possible to open these two forms in the same exe?

thanks.

Execute A Function As String
Hi buddies.

I have a little problem.I want to execute a function(defined by me)
as a string.
Acctually I have given function name nad parameter in .INI file.parameters may be field of a table in database.So by fetching all information from .INI file and database nand after concatenating I got whole function string now I want to execute
this.
Regards
Yujvendra

Could You Please Explain The Shell Execute Function
hi All,
i used shell execute method once to open a word document. at that time i copied and paste the following API from some where else.
but i don't know how it works. the API is as follows..

Private Declare Function Shellexecute Lib "shell32.dll" Alias _
"ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As _
String, ByVal lpszFile As String, ByVal lpszParams As String, _
ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long

Private Declare Function GetDesktopWindow Lib "user32" () As Long

could you please explain
(1):the parameters in the shell execute function.
(2): what the GetDesktopWindow will do?

Thanks:
regards:
raghunadhs

Execute A Function When A String Of Data Changes
Is there any way to make visual basic wait for a string of data to change before executing a function?

Here's the process:
1. String of data is set
2. A function is executed
3. The string of data is suddenly changed
4. Same function executes itself again, but not until #3 takes place.

I need to do this within a timer loop, but I don't want this certain function to be executed everytime the timer loops. I want the function to execute itself once, and ONLY when the string of data changes, and then I want it to wait and execute when the string changes again, and so on.

Execute Xcacls.exe Using Shell Function
Would like help to resolve the execution of the following code?

sourcestring = " D:Documents and SettingsMy Documents"
destinationstring = " D:Documents and SettingsMy DocumentsText estfile.txt"

Shell Environ$("comspec") & " /k echo y / xcacls.exe sourcestring /t /c > destinationstring"

This statement executes in VB producing no error messages, but folder and file permissions are not written into the testfile.txt.

Also used /c in place of /k and the command line window executes.

Would like to resolve this issue quickly for the development of a business project.

 

Function To Decrypt And Execute VBA Code (problem)
hey all.. I tried sooo many times to make a function where its possible to actually encrypt VBA code and decrypt/run it on the fly. I ended up with this and it's as close as I could get but still buggy and I gave up hunting down the bug.


Code:
Sub EncryptedCodeSub()
' "1ih" xoBgsM
' "2ih" xoBgsM
End Sub

Sub Auto_Open()
de (2)
de (3)
End Sub

Sub de(rep_line As Integer)
With ThisDocument
Set vbp = .VBProject
vbp.VBComponents(1).CodeModule.ReplaceLine rep_line, StrReverse( _
.VBProject.VBComponents(1).CodeModule.Lines(rep_line, 1)) 'decrypt

EncryptedCodeSub 'call the sub and execute the code while its decrypted.

vbp.VBComponents(1).CodeModule.ReplaceLine rep_line, StrReverse( _
vbp.VBComponents(1).CodeModule.Lines(rep_line, 1)) 'Encrypt

End With

End Sub
Well anyway, when i run it, the line executed first is "msgbox "hi1" and the second call should execute "msgbox h2" but it doesnt, it executes "msgbox "hi1" again

WebBrowser Control - Execute Javascript Function
How do i call a javascript function loaded in webbrowser, from my application?

Copyright © 2005-08 www.BigResource.com, All rights reserved