|
-
Mar 8th, 2010, 12:49 PM
#1
Thread Starter
Junior Member
1 Through 9
I am doing a statement like this:
If label.text = 1 through 9 Then Blah Blah....
How do I declare 1 through 9?
I tried 1, 2, 3, 4, 5, 6, 7, 8, 9 but that doesnt work.
-
Mar 8th, 2010, 12:52 PM
#2
Fanatic Member
Re: 1 Through 9
I would use a NumericUpDown, if i were you, but...
If CInt(label.Text) >= 1 And CInt(label.Text) <= 9 Then
'whatever
End If
Is that what you're looking for? You weren't very clear in your description.
VB.Net 2008
.Net Framework 2.0
"Must you breathe? 'Cause I need heaven..."
-
Mar 8th, 2010, 12:54 PM
#3
Re: 1 Through 9
You may be better off switching to a Case statement and converting the text to an integer. Something like this:
Code:
Dim intVal As Integer
If Integer.TryParse(Label1.Text, intVal) Then
Select Case intVal
Case 1 To 9
MessageBox.Show(intVal.ToString())
End Select
End If
-
Mar 8th, 2010, 12:55 PM
#4
Thread Starter
Junior Member
Re: 1 Through 9
I am working on a GUI of a Microwave Oven.
I ran into a brick wall with help on here as far as getting the input of the buttons in time format. So I broke the label up into seperate labels for each second, minute and hour. I wanted to declare it so that if the first second is 1-9 and the user hits another button it automatically moves the number over to allow the input of the next.
-
Mar 8th, 2010, 12:58 PM
#5
Thread Starter
Junior Member
Re: 1 Through 9
http://www.vbforums.com/showthread.php?t=602928
This is the link to the original problem if anyone can find the solution... I am stumped...
-
Mar 8th, 2010, 12:59 PM
#6
Thread Starter
Junior Member
Re: 1 Through 9
Here is the GUI of my program if it helps.

I need to be able to have the user type in their time using the keypad I have put on the GUI.
I am having trouble getting the inputted number to turn into a time format.
For example:
If the user inputs 130
I need the display to countdown from: 1:30 and display it in that format.
The max that can be entered is 9:59:59.
The BIGGEST part I need help with is getting the input number to go into time format. HH:MM:SS
Here is the code I have if it helps:
Code:
Option Strict On
Public Class Form1
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
lblYellow.Show()
lblGray.Hide()
lblClock.Hide()
lblTime.Show()
Timer1.Enabled = True
Beep()
End Sub
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
lblYellow.Hide()
lblGray.Show()
lblClock.Show()
lblTime.Text = ""
lblTime.Hide()
Timer1.Enabled = False
Beep()
End Sub
Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
lblYellow.Hide()
lblGray.Show()
If lblTime.Text > "0" Then
lblClock.Hide()
End If
If lblTime.Text = "DONE!" Then
lblTime.Hide()
lblClock.Show()
lblTime.Text = ""
End If
Timer1.Enabled = False
Beep()
End Sub
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
If lblTime.Text = "DONE!" Then
lblTime.Text = ""
End If
If lblTime.Text.Length >= 0 Then lblTime.Text += btn1.Text
Beep()
lblClock.Hide()
lblTime.Show()
End Sub
Private Sub btn2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn2.Click
If lblTime.Text = "DONE!" Then
lblTime.Text = ""
End If
If lblTime.Text.Length >= 0 Then lblTime.Text += btn2.Text
Beep()
lblClock.Hide()
lblTime.Show()
End Sub
Private Sub btn3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn3.Click
If lblTime.Text = "DONE!" Then
lblTime.Text = ""
End If
If lblTime.Text.Length >= 0 Then lblTime.Text += btn3.Text
Beep()
lblClock.Hide()
lblTime.Show()
End Sub
Private Sub btn4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn4.Click
If lblTime.Text = "DONE!" Then
lblTime.Text = ""
End If
If lblTime.Text.Length >= 0 Then lblTime.Text += btn4.Text
Beep()
lblClock.Hide()
lblTime.Show()
End Sub
Private Sub btn5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn5.Click
If lblTime.Text = "DONE!" Then
lblTime.Text = ""
End If
If lblTime.Text.Length >= 0 Then lblTime.Text += btn5.Text
Beep()
lblClock.Hide()
lblTime.Show()
End Sub
Private Sub btn6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn6.Click
If lblTime.Text = "DONE!" Then
lblTime.Text = ""
End If
If lblTime.Text.Length >= 0 Then lblTime.Text += btn6.Text
Beep()
lblClock.Hide()
lblTime.Show()
End Sub
Private Sub btn7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn7.Click
If lblTime.Text = "DONE!" Then
lblTime.Text = ""
End If
If lblTime.Text.Length >= 0 Then lblTime.Text += btn7.Text
Beep()
lblClock.Hide()
lblTime.Show()
End Sub
Private Sub btn8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn8.Click
If lblTime.Text = "DONE!" Then
lblTime.Text = ""
End If
If lblTime.Text.Length >= 0 Then lblTime.Text += btn8.Text
Beep()
lblClock.Hide()
lblTime.Show()
End Sub
Private Sub btn9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn9.Click
If lblTime.Text = "DONE!" Then
lblTime.Text = ""
End If
If lblTime.Text.Length >= 0 Then lblTime.Text += btn9.Text
Beep()
lblClock.Hide()
lblTime.Show()
End Sub
Private Sub btn0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn0.Click
If lblTime.Text = "DONE!" Then
lblTime.Text = ""
End If
If lblTime.Text.Length >= 1 Then lblTime.Text += btn0.Text
Beep()
lblClock.Hide()
lblTime.Show()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim A As Integer
Dim B As Integer
If lblTime.Text > "0" Then
Timer1.Enabled = True
A = CInt(lblTime.Text)
B = 1
lblTime.Text = CStr(A - B)
End If
If lblTime.Text = "0" Then
Beep()
lblTime.Text = "DONE!"
Timer1.Enabled = False
lblYellow.Hide()
lblGray.Show()
End If
If lblTime.Text = "" Then
Timer1.Enabled = False
lblYellow.Hide()
lblGray.Show()
End If
End Sub
Private Sub btnClock_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClock.Click
If lblTime.Text = "" Or Timer1.Enabled = False Then
lblClock.Show()
lblTime.Hide()
lblYellow.Hide()
lblGray.Show()
Timer2.Enabled = True
Timer1.Enabled = False
End If
Beep()
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
lblClock.Text = CStr(TimeOfDay)
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
|