Private Sub AperturaForm() Handles Me.Load
For Each Control As Control In Me.Controls
If TypeOf Control Is Button Then
AddHandler Control.Click, AddressOf GestioneButtons
End If
Next
End Sub
Private Sub GestioneButtons(ByVal sender As Object, ByVal e As EventArgs)
Dim bt As Button = DirectCast(sender, Button)
If bt Is Button2 Then
Timer1.Enabled = False
Return
End If
If bt Is Button3 Then
For Each Control As Control In Me.Controls
If TypeOf Control Is TextBox Then
Control.Text = String.Empty
End If
Next
Return
End If
If bt Is Button5 Then
Timer1.Interval = Int32.Parse(NumericUpDown1.Value.ToString)
Timer1.Enabled = True
Return
End If
If bt Is Button6 Then
NumericUpDown1.Value = 50D
Return
End If
If bt.Text = "Start" Then
bt.Text = "Stop"
Timer1.Interval = Int32.Parse(NumericUpDown1.Value.ToString)
Timer1.Enabled = True
Else
If bt.Text = "Stop" Then
bt.Text = "Start"
Timer1.Enabled = False
End If
End If
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
ToolStripLabel2.Text = Len(TextBox1.Text).ToString
For Each Control As Control In Me.Controls
If TypeOf Control Is TextBox Then
SendKeys.Send((Control.Text))
SendKeys.Send(("{ENTER}"))
End If
Next
End Sub
Private Sub Form2_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
Select Case e.KeyCode
Case Keys.F1
GestioneButtons(Button1, Nothing)
Case Keys.F2
GestioneButtons(Button2, Nothing)
Case Keys.F3
GestioneButtons(Button3, Nothing)
Case Keys.F4
GestioneButtons(Button4, Nothing)
Case Keys.F5
GestioneButtons(Button5, Nothing)
Case Keys.F6
GestioneButtons(Button6, Nothing)
Case Keys.F7
GestioneButtons(Button7, Nothing)
Case Keys.F8
GestioneButtons(Button8, Nothing)
Case Keys.F9
GestioneButtons(Button9, Nothing)
Case Keys.F10
GestioneButtons(Button10, Nothing)
End Select
End Sub