Thread: [PROG]VB VB tijdsintervallen
-
11-09-2007, 15:01 #1
[PROG]VB VB tijdsintervallen
hallo,
Ik ben nu al een tijdje aant programmeren met VB maar ik zit met hetvolgende probleem:
In Turbo Pascal had je een commando "delay(time in ms)" dat ervoor zorgde dat je pc een ingesteld aantal seconde wachtte voor hij de code verderlas.
Dus mijn vraag: heb je een soort gelijkaardig commando in vb ?
dus:
code
delay(....)
verderlezen code na die aantal seconden wachten
bedankt,
Kristof
Voor de mensen die toch nog juist willen schrijven: http://users.pandora.be/kristof999/DT-regels.htmno votes
Reply With Quote
-
-
11-09-2007, 15:55 #2
Hoj
ja hoor
eerst iets declareren als een datum tijd en dan de aantalmilliseconden toevoegen
iets als
Code:'This will pause or timeout your applications code for the specified amount of milli-seconds. ' 'Declare a new DateTime variable and fill it with the current 'time with 2000 milli-seconds added to it. Dim timeOut As DateTime = Now.AddMilliseconds(2000) Do ' 'Keep the app from freezing and allow Windows to continue processing the applications messages. Application.DoEvents() 'Keep looping until the elasped time of 2000 milliseconds. Loop Until Now > timeOut MsgBox("The code paused for: 2000 Milli-Seconds or 2 Seconds!")
[ Momenteel geen signature ]no votes
Reply With Quote
-
11-09-2007, 16:01 #3Member
- Registered
- 10/08/02
- Location
- up in the sky
- Posts
- 3,454
- iTrader
- 0
- Mentioned
- 3 Post(s)
- Reputation
- 0/11
Of,
bovenaan bijvoegen "Imports System.Threading"
en dan
Thread.Sleep(2000) in de code voor een timeout.no votes
Reply With Quote
-
11-09-2007, 16:05 #4
in VB6:
Sleep 2000 ' in milisec
in VB.NET:
System.Threading.Thread.Sleep(2000) ' in milisec
@Raanº³:
DoEvents in een 'lege' Loop zorgt idd niet voor freezing, maar geeft wel 100% Cpu usage. (in VB6 toch, kan niet zeker zeggen voor VB.NET)no votes
Reply With Quote
-
11-09-2007, 17:20 #5Member
- Registered
- 31/05/06
- Location
- Tongeren
- Posts
- 195
- iTrader
- 3 (100%)
- Mentioned
- 0 Post(s)
- Reputation
- 0/0
no votes
Reply With Quote
-
11-09-2007, 23:13 #6
bedankt voor de snelle reacties !
Kristof
Voor de mensen die toch nog juist willen schrijven: http://users.pandora.be/kristof999/DT-regels.htmno votes
Reply With Quote
-
11-09-2007, 23:38 #7
had toch nog graag iets gevraagd:
deze commando's werken niet bij mij, ik gebruik VB6.... Ben wel redelijk noob in die dingen. Heb alleen dos talen geleerd zoals turbo pascal en C.
Kan iemand voor deze commando's duidelijk vertellen wat bovenaan moet en in de code ? Liefst volledig
bedankt,
Kristof
Voor de mensen die toch nog juist willen schrijven: http://users.pandora.be/kristof999/DT-regels.htmno votes
Reply With Quote
-
12-09-2007, 00:17 #8
Wat epsilon toont is alleen voor VB.NET, in VB6 gebruik je:
Code:Option Explicit Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Private Sub Command1_Click() MsgBox "1" Sleep 2000 ' wacht 2 seconden MsgBox "2" End Subno votes
Reply With Quote

