1. #1
    kristofvv's Avatar
    Registered
    17/09/02
    Location
    Blaasveld
    Posts
    167
    iTrader
    0
    Mentioned
    0 Post(s)
    Reputation
    0/0

    [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.htm
    no votes   Reply With Quote Reply With Quote

  2. #2
    Raanº³'s Avatar
    Registered
    19/07/02
    Location
    Drongen
    Posts
    1,083
    iTrader
    0
    Mentioned
    0 Post(s)
    Reputation
    0/1
    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 Reply With Quote

  3. #3
    epsilon's Avatar
    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 Reply With Quote

  4. #4
    R3Deye's Avatar
    Registered
    28/01/06
    Location
    Antwerp City
    Posts
    45
    iTrader
    0
    Mentioned
    0 Post(s)
    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 Reply With Quote

  5. #5

    Registered
    31/05/06
    Location
    Tongeren
    Posts
    195
    iTrader
    3 (100%)
    Mentioned
    0 Post(s)
    Reputation
    0/0
    Quote Originally Posted by R3Deye View Post
    This quote is hidden because you are ignoring this member. Show
    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)

    deze manier is idd the way to go
    Insert sig here...
    no votes   Reply With Quote Reply With Quote

  6. #6
    kristofvv's Avatar
    Registered
    17/09/02
    Location
    Blaasveld
    Posts
    167
    iTrader
    0
    Mentioned
    0 Post(s)
    Reputation
    0/0
    bedankt voor de snelle reacties !

    Kristof
    Voor de mensen die toch nog juist willen schrijven: http://users.pandora.be/kristof999/DT-regels.htm
    no votes   Reply With Quote Reply With Quote

  7. #7
    kristofvv's Avatar
    Registered
    17/09/02
    Location
    Blaasveld
    Posts
    167
    iTrader
    0
    Mentioned
    0 Post(s)
    Reputation
    0/0
    Quote Originally Posted by epsilon View Post
    This quote is hidden because you are ignoring this member. Show
    Of,
    bovenaan bijvoegen "Imports System.Threading"
    en dan
    Thread.Sleep(2000) in de code voor een timeout.
    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.htm
    no votes   Reply With Quote Reply With Quote

  8. #8
    R3Deye's Avatar
    Registered
    28/01/06
    Location
    Antwerp City
    Posts
    45
    iTrader
    0
    Mentioned
    0 Post(s)
    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 Sub
    no votes   Reply With Quote Reply With Quote

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Log in

Log in