|
-
Oct 30th, 2007, 06:49 PM
#1
Thread Starter
Junior Member
Help with text boxes and timer controls
Hello, I am very new to Visual Basic and have hit a couple snags. Below is all of my code. I am supposed to be making a program like a microwave. The text box that displays the time should only show 2 numbers for the minutes, a ":" and 2 numbers for the seconds. I have set the max length for the text box to 5 but when the buttons are clicked more than five numbers will show up. Also, the ":" doesn't stay in the middle, I have tried to use the substring to break the numbers up, but that isn't working for me.
My other problem is that this time that can be entered is also supposed to run like a timer. I have added the timer control and think that I need to use the interval to make this work, but I am not sure. I can't get the numbers back from the text box as an integer for that to work because option strict and VB won't let me....
Any help is really appreciated...
Champ0342
Option Strict On
Public Class Form1
Dim b(9) As String
Private Sub form1_load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim display(9) As String
'button values
b(0) = "0"
b(1) = "1"
b(2) = "2"
b(3) = "3"
b(4) = "4"
b(5) = "5"
b(6) = "6"
b(7) = "7"
b(8) = "8"
b(9) = "9"
tbtime.Text = "00:00"
tbtime.MaxLength = 5
End Sub
Private Sub btnone_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnone.Click
tbtime.Text = tbtime.Text & b(1)
End Sub
Private Sub btntwo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntwo.Click
tbtime.Text = tbtime.Text & b(2)
End Sub
Private Sub btnthree_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnthree.Click
tbtime.Text = tbtime.Text & b(3)
End Sub
Private Sub btnfour_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfour.Click
tbtime.Text = tbtime.Text & b(4)
End Sub
Private Sub btnfive_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnfive.Click
tbtime.Text = tbtime.Text & b(5)
End Sub
Private Sub btnsix_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsix.Click
tbtime.Text = tbtime.Text & b(6)
End Sub
Private Sub btnseven_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnseven.Click
tbtime.Text = tbtime.Text & b(7)
End Sub
Private Sub btneight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btneight.Click
tbtime.Text = tbtime.Text & b(8)
End Sub
Private Sub btnnine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnnine.Click
tbtime.Text = tbtime.Text(0) & b(9)
End Sub
Private Sub btnzero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnzero.Click
tbtime.Text = tbtime.Text & b(0)
End Sub
Private Sub btnstart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnstart.Click
tmrtime.Enabled = True
If tmrtime.Enabled = True Then
pbwindow.BackColor = Color.Yellow
End If
End Sub
Private Sub btnstop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnstop.Click
Dim pause As String
pause = "Pause"
tmrtime.Enabled = False
If tmrtime.Enabled = False Then
pbwindow.BackColor = Color.LightGray
End If
If tmrtime.Enabled = False Then
tbtime.Text = pause
End If
End Sub
Private Sub tbtime_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbtime.TextChanged
tbtime.MaxLength = 5
End Sub
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|