Aug 7, 2008

[vb.net 2k5] Countdown (help) - countdown visual basic 2005 2k5

Free Web Hosting, No Ads > CONTRIBUTE > Computers > Programming Languages > .NET ( ASP.net VB.net )

free web hosting

[vb.net 2k5] Countdown (help) - countdown visual basic 2005 2k5

de4thpr00f
Hello, i'm having some troubles creating a countdown, i'm willing for some help.

First of all, the form has a textbox where the user has to input the time to countdown like this: 1:10 < this means 1 minute and 10 seconds
the form has also 3 labels, 1 named countminutes, other countseconds and another label1 with the text ":"
here's the code, the problem is that it counts the time, but blocks the app till it ends, wich result on not showing the counttime like it should:
CODE
Imports System.Threading.Thread

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim time() As String
time = Split(timetowait.Text, ":", , CompareMethod.Text)
countminutes.Text = time(0)
countseconds.Text = time(1)
Dim minutes As Integer = time(0)
Dim seconds As Integer = time(1)
start:
If seconds = 0 And minutes = 0 Then
GoTo stops
End If
If seconds = 0 Then
minutes -= 1
seconds = 60
End If
seconds -= 1
countminutes.Text = minutes
countseconds.Text = seconds
Sleep(1000)
GoTo start
stops:
MsgBox("countdown off")
End Sub
End Class



If someone could help me would be cool.
If i pull this out before someone helps me i'll post the new code in here.
Thanks in advance.

~
Joćo Lopes

*edit*
Posted the attached file.


*edit*
Problem solved, i'll leave the 1st source there and attach another, the 1st source has nothing important, but uses the function sleep, and i don't know if it will not be needed around.

and the code is this one (note, now a timer is needed, named timer1)
CODE
Imports System.Threading.Thread

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If InStr(timetowait.Text, ":") Then
Dim time() As String
time = Split(timetowait.Text, ":", , CompareMethod.Text)
countminutes.Text = time(0)
countseconds.Text = time(1)
Timer1.Interval = 1000
Timer1.Start()
Else
MsgBox("You have to insert like this 1:10")
End If
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim minutes As Integer = countminutes.Text
Dim seconds As Integer = countseconds.Text
If minutes = 0 And seconds = 0 Then
MsgBox("Time Ended")
Timer1.Stop()
End If
If seconds = 0 Then
minutes -= 1
seconds += 60
End If
seconds -= 1
If minutes <> -1 Then
countminutes.Text = minutes
countseconds.Text = seconds
End If
End Sub
End Class

 

 

 


Reply

paulbacca
Hi de4thpr00f,
would you know how to add hours to your code below. I would appreciate any help you can give.
Thanks
Paul


[quote name='de4thpr00f' date='Nov 21 2007, 02:15 PM' post='358108']

CODE
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim time() As String
time = Split(timetowait.Text, ":", , CompareMethod.Text)
countminutes.Text = time(0)
countseconds.Text = time(1)
Dim minutes As Integer = time(0)
Dim seconds As Integer = time(1)
start:
If seconds = 0 And minutes = 0 Then
GoTo stops
End If
If seconds = 0 Then
minutes -= 1
seconds = 60
End If
seconds -= 1
countminutes.Text = minutes
countseconds.Text = seconds
Sleep(1000)
GoTo start
stops:
MsgBox("countdown off")
End Sub
End Class

 

 

 


Reply

imbibe
You can convert hours to seconds and add them to the code.
BTW for timer there's inbuilt control for Desktop & Web (using ASP.NET AJAX 1.0) Applications.

Set the Interval property to seconds, minutes, even hours, days. Then handle the Tick Event.

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. creating a countdown timer and stop watch timer using vb 6.0 - 241.93 hr back. (1)
  2. timer .net countdown vs2005 - 391.34 hr back. (1)
  3. "visual basic .net" countdown timer - 418.80 hr back. (1)
Similar Topics

Keywords : , vb, net, 2k5, countdown, countdown, visual, basic, 2005, 2k5

  1. Countdown Timer
    (0)
  2. [vb.net 2k5] Color Fading Textboxes
    vb .net visual basic color fading textbox 2k5 2005 (0)
    Ok, here's another good application, but it has not been made by me, i can't remember the
    source of it to give credits to. But anyway it's a good application to use in forms, when
    someone forget to insert a data... take a look. greetz ~ Joćo Lopes....
  3. [vb.net 2k5] Morsecode
    Morse code vb.net visual basic .net 2005 2k5 (0)
    Well, here's the source of a program that interacts with the pc speaker, i made it to "beep"
    like a morse code, depending on the text. Study the code if you will, although it's very simple,
    but here it is /rolleyes.gif" style="vertical-align:middle" emoid=":rolleyes:" border="0"
    alt="rolleyes.gif" /> Note: If you don't have vb.net installed and want to test the program,
    run the executable on the folder "morsecode\obj\Release" /wink.gif"
    style="vertical-align:middle" emoid=";)" border="0" alt="wink.gif" />....
  4. Visual Basic.net New Videos
    Here you will find a nice videos explaining vb.net (4)
    Hello Everybody, look at this nice learning videos for vb.net 1- How
    to use the ListView Control Part 1: Basics Demonstrates the basics of creating ListViewItems,
    changing the display mode, and adding columns for the Details view. Download 2- How to use the
    ListView Control Part 2: Advanced Demonstrates a few advanced concepts related to the ListView
    control and populating it with database data and syncing changes to ListViewItems back into the
    database. Download 3- How to use the TreeView Control Demonstrates how to create TreeNo....
  5. New Features In Visual Studio 2005 Windows Forms
    Updated IDE features, new Menu, Toolstrip and multimedia controls, sup (0)
    New Features in Visual Studio 2005 Windows Forms QUOTE The little voice in my head shouted
    "Don't do it! Don't do it!" as I contemplated using the worn out cliché "Good things
    come to those who wait" to describe the experience of designing Windows applications with Visual
    Studio 2005. However, that cliché accurately communicates the idea that building Windows Forms
    applications in Visual Studio 2005 is better, makes you more productive, and is more fun than doing
    the same task in Visual Studio 2003, not to mention VB6! Part of what makes work....

    1. Looking for , vb, net, 2k5, countdown, countdown, visual, basic, 2005, 2k5

Searching Video's for , vb, net, 2k5, countdown, countdown, visual, basic, 2005, 2k5
advertisement



[vb.net 2k5] Countdown (help) - countdown visual basic 2005 2k5



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE