Results 1 to 7 of 7

Thread: Time

  1. #1
    Guest

    Arrow

    How do i unload a form after it has loaded and visible for 10 seconds.

  2. #2
    Addicted Member JasonGS's Avatar
    Join Date
    May 2000
    Location
    California
    Posts
    155
    Code:
    Private Sub Form_Load()
        Form1.Visible = True
        OpenedAt = Now
        Do Until DateDiff("s", OpenedAt, Now) >= 10
            DoEvents
        Loop
        Unload Form1
    End Sub

  3. #3
    Guest
    Or you can use a Timer with the Interval set to 1000. (1 second)

    [code]
    Private Sub Timer1_Timer()

    Static tCount
    tCount = tCount + 1
    If tCount = 10 Then Unload Me

    End Sub

  4. #4
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    Hope it helpz

    Im sure there are better ways, but im new and untill then maybe this will help.

    First create a timer and form and module.

    in module put

    Global hours, mins, seconds as integer

    then in form1_load put

    hours = 0
    mins = 0
    seconds = 10
    form1.timer1.enabled = true
    (set interval on timer to 1000)

    This will count down the timer in 10 seconds....now

    in timer1 put

    if seconds = 0 then
    seconds = 59
    if mins = 0 then
    mins = 59
    if hours = 0 then
    form1.unload
    else
    hours = hours - 1
    end if
    else
    mins = mins -1
    end if
    else seconds = seconds - 1
    end if

    if len(mins) < 2 then mins = "0" & mins
    if len(seconds) <2 then seconds = "0" & seconds

    label2.caption = hours & ":" & mins & ":" & seconds

    end sub

    Hope that works....kind of slopy, be sure to check for typo's if get a error...see ya



    -RaY
    VB .Net 2010 (Ultimate)

  5. #5
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    PS I FORGOT

    Create a label2 as well, this way you can see the 10 seconds count down to make sure its working.
    -RaY
    VB .Net 2010 (Ultimate)

  6. #6
    Hyperactive Member
    Join Date
    May 2000
    Posts
    344

    Talking ROFL

    Thats y my programs are so buggy, look at there code and look at mind, geesh all that extra work I do.... I can probably make opening up a text file 4 megz of source...hehe....oh well i tried.
    -RaY
    VB .Net 2010 (Ultimate)

  7. #7
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Two other ways:
    The first is accurate to 1ms, the second to 60ms
    Code:
    'In declarations
    Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
    'In code
    t=gettickcount+10000
    Do while t>gettickcount
     doevents
    loop
    Code:
    t=timer+10
    Do while t>timer
     doevents
    loop
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

Posting Permissions

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



Click Here to Expand Forum to Full Width