[VB2008] Click O Thon-VBForums
Results 1 to 4 of 4

Thread: [VB2008] Click O Thon

Hybrid View

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2009
    Location
    Canada/Quebec
    Posts
    54

    [VB2008] Click O Thon

    Click O Thon

    The Form:


    Be sure to Disable The Start button and the CLICK!!!! button...

    PHP Code:
    Public Class Form1

        
    Private Sub Button3_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button3.Click
            
    If Timer1.Interval "170" Then
                ProgressBar1
    .Value -= 2
            End 
    If
            If 
    Timer1.Interval "50" Then
                ProgressBar1
    .Value -= 2
            End 
    If
            If 
    Timer1.Interval "20" Then
                ProgressBar1
    .Value -= 3
            End 
    If

        
    End Sub

        
    Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button1.Click

            Timer1
    .Start()
            
    Timer2.Start()
            
    Button3.Enabled True
            Button4
    .Enabled False
            Button5
    .Enabled False
            Button6
    .Enabled False
        End Sub

        
    Private Sub Timer1_Tick(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Timer1.Tick
            ProgressBar1
    .Increment(1)
            If 
    ProgressBar1.Value ProgressBar1.Maximum Then
                Timer1
    .Stop()
                
    Label1.Text "YOU FAIL!!!"
            
    End If
            If 
    ProgressBar1.Value "5" Then
                Timer1
    .Enabled False
                Button3
    .Enabled False
                Label1
    .Text "YOU WIN!!!"
                
    Timer2.Stop()
            
    End If
            If 
    ProgressBar1.Value "4" Then
                Timer1
    .Enabled False
                Button3
    .Enabled False
                Label1
    .Text "YOU WIN!!!"
                
    Timer2.Stop()
            
    End If
            If 
    ProgressBar1.Value "3" Then
                Timer1
    .Enabled False
                Button3
    .Enabled False
                Label1
    .Text "YOU WIN!!!"
                
    Timer2.Stop()
            
    End If
            If 
    ProgressBar1.Value "2" Then
                Timer1
    .Enabled False
                Button3
    .Enabled False
                Label1
    .Text "YOU WIN!!!"
                
    Timer2.Stop()
            
    End If
            If 
    ProgressBar1.Value "1" Then
                Timer1
    .Enabled False
                Button3
    .Enabled False
                Label1
    .Text "YOU WIN!!!"
                
    Timer2.Stop()
            
    End If
        
    End Sub

        
    Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgsHandles MyBase.Load

        End Sub

        
    Private Sub Button2_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button2.Click
            Label2
    .Text "60"
            
    ProgressBar1.Value 35
            Label1
    .Text ""
            
    Timer1.Stop()
            
    Button3.Enabled False
            Button4
    .Enabled True
            Button5
    .Enabled True
            Button6
    .Enabled True
            Button1
    .Enabled True
        End Sub

        
    Private Sub Button4_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button4.Click
            Timer1
    .Interval "170"
            
    Button4.Enabled False
            Button6
    .Enabled True
            Button6
    .Enabled True
        End Sub

        
    Private Sub Button5_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button5.Click
            Timer1
    .Interval "50"
            
    Button4.Enabled True
            Button5
    .Enabled False
            Button6
    .Enabled True
        End Sub

        
    Private Sub Button6_Click(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Button6.Click
            Timer1
    .Interval "20"
            
    Button4.Enabled True
            Button5
    .Enabled True
            Button6
    .Enabled False
        End Sub

        
    Private Sub Timer2_Tick(ByVal sender As System.ObjectByVal e As System.EventArgsHandles Timer2.Tick
            Label3
    .Text Label2.Text 1
        End Sub
    End 
    Class 
    Credits To DaneX
    Learning VB2008
    Developer DaneX

  2. #2
    New Member
    Join Date
    Jul 2009
    Posts
    2

    Re: [VB2008] Click O Thon

    Thanks, I edited at
    Code:
    YOU FAIL!!!

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 2009
    Location
    Canada/Quebec
    Posts
    54

    Re: [VB2008] Click O Thon

    You are welcome! enjoy =P
    Learning VB2008
    Developer DaneX

  4. #4
    New Member
    Join Date
    Aug 2003
    Location
    Pekin, IL
    Posts
    1

    Re: [VB2008] Click O Thon

    You should tighten up that code and get rid of unnecessary conditionals.

    You will also note that I used a different conditional for the button clicks (SELECT CASE) and combined event handlers for those three buttons. In doing so you eliminate a bit of code, and you can use the "sender" to determine which button was pressed.

    This was written on the fly in the forum editor so I could conceivably have a syntax error or something in it as it stands... but it should be solid.

    Code:
    Public Class Form1
        Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
            If Timer1.Interval = 20 then
                ProgressBar1.Value -= 3
            Else
                Progressbar1.Value -= 2
            End If
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Timer1.Start()
            Timer2.Start()
            Button3.Enabled = True
            Button4.Enabled = False
            Button5.Enabled = False
            Button6.Enabled = False
        End Sub
    
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            ProgressBar1.Increment(1)
            If ProgressBar1.Value = ProgressBar1.Maximum Then
                Timer1.Stop()
                Label1.Text = "YOU FAIL!!!"
            ElseIf ProgressBar1.Value <= 5 Then
                Timer1.Enabled = False
                Button3.Enabled = False
                Label1.Text = "YOU WIN!!!"
                Timer2.Stop()
            End If
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Label2.Text = "60"
            ProgressBar1.Value = 35
            Label1.Text = ""
            Timer1.Stop()
            Button3.Enabled = False
            Button4.Enabled = True
            Button5.Enabled = True
            Button6.Enabled = True
            Button1.Enabled = True
        End Sub
    
        Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click, Button5.Click, Button6.Click
            Select Case sender.text
                Case "Easy"
                    Timer1.Interval = "170"
                    Button4.Enabled = False
                    Button6.Enabled = True
                    Button6.Enabled = True
                Case "Medium"
                    Timer1.Interval = "50"
                    Button4.Enabled = True
                    Button5.Enabled = False
                    Button6.Enabled = True
                Case "Harcore!!!!"
                    Timer1.Interval = "20"
                    Button4.Enabled = True
                    Button5.Enabled = True
                    Button6.Enabled = False
            End Select
        End Sub
    
        Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
            Label3.Text = Label2.Text - 1
        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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.