Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sleep compliation problem 1

Status
Not open for further replies.

bastienk

Programmer
Joined
Mar 3, 2004
Messages
326
Location
CA
Hi All,

I am trying to create a sleep fucntion for an ASP app to use.

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

When I try to compile this into a .dll I get a compile error
"Invalid outside procedure"

How can I fix this?

TIA


Bastien

Cat, the other other white meat
 
:-)
This goes at the top of the code window:
Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)

Then in code call it from another sub or function like so:
Private Sub Command1_Click()
Call Sleep(1000)
End Sub








"Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'."
 
Well, my plan is to make this an ASP callable object on the server...will that approach still work. ASP does not have a default sleep object and running a for loop would kill the processer.

Basically I want to do this
Code:
'asp page
dim MySleeper
set MySleeper = server.CreateObject("sleeper.sleeps")

'call the sleep function
MySleeper

'wake up and do something else


Bastien

Cat, the other other white meat
 
hmmm, in vb do something like this:

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

Public Sub GotoSleep(intMilliseconds As Integer)
Sleep intMilliseconds
End Sub

Compile the dll and register it on the server:


Then call like this:

Set oSleep = CreateObject("sleeper.sleeps")
oSleep.gotoSleep 100

"Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'."
 
Thanks. That got that part solved.

As usual, its not the end though. The ASP page can't instantiate the object...

Error Type:
Microsoft VBScript runtime (0x800A01AD)
ActiveX component can't create object: 'sleeper.sleeps'




Bastien

Cat, the other other white meat
 
When you compiled the dll did you call the project sleeper
and the class sleeps?
Set oSleep = CreateObject("projectname.classname")


"Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'."
 
yep...could it an incorrect registration on the server...

i simply ran

regsvr32 sleeper.dll


Bastien

Cat, the other other white meat
 
Open the registry editor and do a search for sleeper.dll and see how it was registered.

"Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'."
 
Thanks, got it solved. Was a threading error (apartment vs single)...

Appreciate your time...


Bastien

Cat, the other other white meat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top