Dim The_Text As String
Dim chkStr As String
Dim Curent_Char, mistakes_Count As Integer
Dim l2 As New Form2
Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
My.Computer.Audio.Stop()
If mistakes_Count = 0 Then
sound(Curent_Char)
mistakes_Count = 1
Exit Sub
End If
chkStr = Mid(The_Text, Curent_Char, 1)
If chkStr = "a" Then
If e.KeyChar = chkStr Then
Label2.Text &= Mid(The_Text, Curent_Char, 1)
Curent_Char += 1
sound(Curent_Char)
Else
sound(Curent_Char)
sound(0)
End If
ElseIf chkStr = "s" Then
If e.KeyChar = chkStr Then
Label2.Text &= Mid(The_Text, Curent_Char, 1)
Curent_Char += 1
sound(Curent_Char)
Else
sound(0)
End If
ElseIf chkStr = "d" Then
If e.KeyChar = chkStr Then
Label2.Text &= Mid(The_Text, Curent_Char, 1)
Curent_Char += 1
sound(Curent_Char)
Else
sound(0)
End If
ElseIf chkStr = "f" Then
If e.KeyChar = chkStr Then
Label2.Text &= Mid(The_Text, Curent_Char, 1)
Curent_Char += 1
sound(Curent_Char)
Else
sound(0)
End If
ElseIf chkStr = "j" Then
If e.KeyChar = chkStr Then
Label2.Text &= Mid(The_Text, Curent_Char, 1)
Curent_Char += 1
sound(Curent_Char)
Else
sound(0)
End If
ElseIf chkStr = "k" Then
If e.KeyChar = chkStr Then
Label2.Text &= Mid(The_Text, Curent_Char, 1)
Curent_Char += 1
sound(Curent_Char)
Else
sound(0)
End If
ElseIf chkStr = "l" Then
If e.KeyChar = chkStr Then
Label2.Text &= Mid(The_Text, Curent_Char, 1)
Curent_Char += 1
sound(Curent_Char)
MsgBox("xxx", MsgBoxStyle.YesNo)
If True Then
l2.Show()
Else
'Form1_Load()
End If
Else
sound(0)
End If
Else
End If
'MsgBox(mistakes_Count & " " & e.KeyChar)
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
The_Text = (Label1.Text & Label3.Text)
mistakes_Count = 0
Curent_Char = 1
End Sub
Private Sub sound(ByVal s)
If s = 1 Then
My.Computer.Audio.Play(My.Resources.lesson1_a, AudioPlayMode.Background)
ElseIf s = 2 Then
My.Computer.Audio.Play(My.Resources.lesson1_s, AudioPlayMode.Background)
ElseIf s = 3 Then
My.Computer.Audio.Play(My.Resources.lesson1_d, AudioPlayMode.Background)
ElseIf s = 4 Then
My.Computer.Audio.Play(My.Resources.lesson1_f, AudioPlayMode.Background)
ElseIf s = 5 Then
My.Computer.Audio.Play(My.Resources.lesson1_j, AudioPlayMode.Background)
ElseIf s = 6 Then
My.Computer.Audio.Play(My.Resources.lesson1_k, AudioPlayMode.Background)
ElseIf s = 7 Then
My.Computer.Audio.Play(My.Resources.lesson1_l, AudioPlayMode.Background)
ElseIf s = 0 Then
My.Computer.Audio.Play(My.Resources._false, AudioPlayMode.Background) 'เสียงผิด
End If