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!

Very odd! VB is now programming itself!!!!

Status
Not open for further replies.

elziko

Programmer
Joined
Nov 7, 2000
Messages
486
Location
GB
I posted earlier on about getting VB to wait until finished accessing a file. Nobody replied so I've been mucking around. I tried to but this in between the file access and the next command:

Time = Timer
Do Until Timer = Time + 1
Loop

This sometimes seems to work giving enought time for the accessing to finish. However, most of the time it seems to stick in the loop. When this happens I ctrl-break the program and see that VB has added many "Next" commands and moved the "Loop" command somewhere else.

Has my copy of VB become self-aware and now views my poor programming skills as a threat??

Has anyone else ever had a copy of VB capable of self programming?

I'd be amazed if anyone can give me an explanation of this!

elziko
 
You should not use the equality test in this situation. The result of Time+1 would have to exactly match the value of timer. This value has the precision of a single, so the odds of this ever matching is slim to none. You can use the timer function like this:
Code:
Dim StartTime As Single

StartTime = Timer
Do While Timer < StartTime + 1
    DoEvents
Loop
If you are not processing anything, you can use the API Sleep function to pause the application for a specified amount of time.
Code:
Declare Sub Sleep Lib &quot;kernel32&quot; (ByVal dwMilliseconds As Long)

Sleep dwMilliseconds

Hope this helps!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top