Help needed in vb

harintheman

Member
Jul 5, 2008
3,934
23
0
?
Plzzzz help machanla i want to know how to set a countdown timer for a text box i want the text box to countdown from 60 seconds to 0 seconds and when the countdown is finished another form must load exiting the existing one
:nerd::nerd::nerd:
plzzz helpppp
 

kosandpol

Well-known member
  • Jun 10, 2008
    45,329
    1,492
    113
    use a timer control.
    Set the interval on the control to 1 second and on the launch event, reduce 1 from the last value in the text box.
     

    kasun0777

    Well-known member
  • May 27, 2009
    4,166
    1
    529
    113
    37
    Panadura
    Timer eke interval:6000 k denna.

    Label 1 Propeties
    Name:lbltime
    Caption: " "

    Timer Proprties
    Name : timer1
    Interval : 6000


    Private Sub Timer1_timer( )
    lbltime.caption=time
    End Sub
     

    xcorect

    Well-known member
  • Apr 17, 2007
    7,881
    84
    48
    insert timer and text box
    change textbox name as txttime
    insert another form
    set the interval in timer for 600


    code is below
    Dim a As Integer

    Private Sub Form_Load()
    a = Timer1.Interval

    End Sub

    Private Sub Timer1_Timer()
    a = a - 10
    txttime = a / 10
    If a = 0 Then
    Load Form2
    Form2.Visible = True
    Timer1.Enabled = False
    End If

    End Sub
     

    OptiplexFx

    Member
    May 29, 2009
    2,568
    44
    0
    cyberspace
    I haven't programmed in VB, therefore I cant give you the exact syntax. but I'll tell you what to do then you can do it in VB.

    Add a timer control. Declare a global variable, lets say Counter and initialize it to 60. Then in the timer tick event; I belive in VB it will look something like Private Sub Timer1_Timer() decrement Counter by one (this will make it count down from 60 at each timer tick event). At the same time set the textbox's text property to Counter. Have a check inside the tick event handler to check the value of Counter, When it reaches 0 stop the timer and launch the new window.

    EDIT : Didnt see xcorect's post..., he has given the complete code.. LOL..
     
    Last edited:

    ¤--bACarDi--¤

    Well-known member
  • Jan 9, 2009
    12,130
    288
    83
    124.43.xxx.xxx
    Private sub Form_Load ()
    Timer1.interval = 1000
    Text box1.text = 60
    timer1.enable = True

    Ens sub

    Private sub Timer1_Timer()
    Textbox1.text = val(Textbox1.Text - 1)

    if Textbox1.text = 0 then
    Form2.visible = True
    Form1.visible = False
    Timer1.enable = False
    end if

    End sub


    Ohoma neda ?? :nerd: Mata VB mathaka ne ban den :(