Results 1 to 6 of 6

Thread: 1 Through 9

  1. #1

    Thread Starter
    Junior Member EiNST3iN's Avatar
    Join Date
    Oct 2009
    Posts
    26

    Unhappy 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.

  2. #2
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    675

    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..."

  3. #3
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    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

  4. #4

    Thread Starter
    Junior Member EiNST3iN's Avatar
    Join Date
    Oct 2009
    Posts
    26

    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.

  5. #5

    Thread Starter
    Junior Member EiNST3iN's Avatar
    Join Date
    Oct 2009
    Posts
    26

    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...

  6. #6

    Thread Starter
    Junior Member EiNST3iN's Avatar
    Join Date
    Oct 2009
    Posts
    26

    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
  •  



Click Here to Expand Forum to Full Width