was able to do this easily in VB6, but I am not able to get this to happen in VB.NET. Can you help?
Requires Free Membership to View
When you register, you'll begin receiving targeted emails from my team of award-winning writers. Our goal is to provide a unique online resource for developers, architects and development managers tasked with building and maintaining enterprise applications using Visual Basic, C# and the Microsoft .NET platform.
Hannah Smalltree, Editorial Director-
Public Class Form1 Inherits System.Windows.Forms.Form Private m_CountDown As Int32 = 0 Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click Try m_CountDown = Convert.ToInt32(TextBox1.Text, 10) Catch ex As FormatException ' Means it's not a number in the text box. m_CountDown = 0 End Try If (m_CountDown > 0) Then Label1.Text = TextBox1.Text Button1.Enabled = False TextBox1.Enabled = False Timer1.Start() End If End Sub Private Sub Timer1_Tick(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Timer1.Tick m_CountDown = m_CountDown - 1 Label1.Text = m_CountDown.ToString() If (m_CountDown = 0) Then TextBox1.Enabled = True Button1.Enabled = True Timer1.Stop() End If End Sub End Class 0) Then Label1.Text = TextBox1.Text Button1.Enabled = False TextBox1.Enabled = False Timer1.Start() End If End Sub Private Sub Timer1_Tick(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Timer1.Tick m_CountDown = m_CountDown - 1 Label1.Text = m_CountDown.ToString() If (m_CountDown = 0) Then TextBox1.Enabled = True Button1.Enabled = True Timer1.Stop() End If End Sub End Class
This was first published in November 2003