Читаем Справочник Жаркова по проектированию и программированию искусственного интеллекта. Том 5: Программирование искусственного интеллекта на Visual Basic (продолжение 1) полностью

На первой форме Form1 в режиме проектирования дважды щёлкаем по кнопке Button с именем для первой буквы используемого в данной игре английского алфавита Name = A (или в панели Properties для этого элемента на вкладке Events дважды щёлкаем по имени соответствующего события).

Появившийся шаблон метода после записи нашего кода принимает следующий вид.

Листинг 19.2. Метод-обработчик щелчка кнопки.

Private Sub A_Click(ByVal sender As System.Object, _

ByVal e As System.EventArgs) Handles A.Click

A.Enabled = False

nums = Len(Word_in.Text)

Try

str(0) = Mid(Word_in.Text, nums, 1)

str(1) = Mid(Word_in.Text, nums – 1, 1)

str(2) = Mid(Word_in.Text, nums – 2, 1)

str(3) = Mid(Word_in.Text, nums – 3, 1)

str(4) = Mid(Word_in.Text, nums – 4, 1)

str(5) = Mid(Word_in.Text, nums – 5, 1)

str(6) = Mid(Word_in.Text, nums – 6, 1)

str(7) = Mid(Word_in.Text, nums – 7, 1)

str(8) = Mid(Word_in.Text, nums – 8, 1)

str(9) = Mid(Word_in.Text, nums – 9, 1)

str(10) = Mid(Word_in.Text, nums – 10, 1)

str(11) = Mid(Word_in.Text, nums – 11, 1)

str(12) = Mid(Word_in.Text, nums – 12, 1)

str(13) = Mid(Word_in.Text, nums – 13, 1)

str(14) = Mid(Word_in.Text, nums – 14, 1)

str(15) = Mid(Word_in.Text, nums – 15, 1)

str(16) = Mid(Word_in.Text, nums – 16, 1)

str(17) = Mid(Word_in.Text, nums – 17, 1)

str(18) = Mid(Word_in.Text, nums – 18, 1)

str(19) = Mid(Word_in.Text, nums – 19, 1)

Catch ex As Exception

End Try

If Word_in.TextLength = 1 Then

If str(0) = "a" Then

Chr1.Text = "A"

End If

ElseIf Word_in.TextLength = 2 Then

If str(1) = "a" Then

Chr1.Text = "A"

End If

If str(0) = "a" Then

Chr2.Text = "A"

End If

ElseIf Word_in.TextLength = 3 Then

If str(0) = "a" Then

Chr3.Text = "A"

End If

If str(1) = "a" Then

Chr2.Text = "A"

End If

If str(2) = "a" Then

Chr1.Text = "A"

End If

ElseIf Word_in.TextLength = 4 Then

If str(0) = "a" Then

Chr4.Text = "A"

End If

If str(1) = "a" Then

Chr3.Text = "A"

End If

If str(2) = "a" Then

Chr2.Text = "A"

End If

If str(3) = "a" Then

Chr1.Text = "A"

End If

ElseIf Word_in.TextLength = 5 Then

If str(0) = "a" Then

Chr5.Text = "A"

End If

If str(1) = "a" Then

Chr4.Text = "A"

End If

If str(2) = "a" Then

Chr3.Text = "A"

End If

If str(3) = "a" Then

Chr2.Text = "A"

End If

If str(4) = "a" Then

Chr1.Text = "A"

End If

ElseIf Word_in.TextLength = 6 Then

If str(0) = "a" Then

Chr6.Text = "A"

End If

If str(1) = "a" Then

Chr5.Text = "A"

End If

If str(2) = "a" Then

Chr4.Text = "A"

End If

If str(3) = "a" Then

Chr3.Text = "A"

End If

If str(4) = "a" Then

Chr2.Text = "A"

End If

If str(5) = "a" Then

Chr1.Text = "A"

End If

ElseIf Word_in.TextLength = 7 Then

If str(0) = "a" Then

Chr7.Text = "A"

End If

If str(1) = "a" Then

Chr6.Text = "A"

End If

If str(2) = "a" Then

Chr5.Text = "A"

End If

If str(3) = "a" Then

Chr4.Text = "A"

End If

If str(4) = "a" Then

Chr3.Text = "A"

End If

If str(5) = "a" Then

Chr2.Text = "A"

End If

If str(6) = "a" Then

Chr1.Text = "A"

End If

ElseIf Word_in.TextLength = 8 Then

If str(0) = "a" Then

Chr8.Text = "A"

End If

If str(1) = "a" Then

Chr7.Text = "A"

End If

If str(2) = "a" Then

Chr6.Text = "A"

End If

If str(3) = "a" Then

Chr5.Text = "A"

End If

If str(4) = "a" Then

Chr4.Text = "A"

End If

If str(5) = "a" Then

Chr3.Text = "A"

End If

If str(6) = "a" Then

Chr2.Text = "A"

End If

If str(7) = "a" Then

Chr1.Text = "A"

End If

ElseIf Word_in.TextLength = 9 Then

If str(0) = "a" Then

Chr9.Text = "A"

End If

If str(1) = "a" Then

Chr8.Text = "A"

End If

If str(2) = "a" Then

Chr7.Text = "A"

End If

If str(3) = "a" Then

Chr6.Text = "A"

End If

If str(4) = "a" Then

Chr5.Text = "A"

End If

If str(5) = "a" Then

Chr4.Text = "A"

End If

If str(6) = "a" Then

Chr3.Text = "A"

End If

If str(7) = "a" Then

Chr2.Text = "A"

End If

If str(8) = "a" Then

Chr1.Text = "A"

End If

ElseIf Word_in.TextLength = 10 Then

If str(0) = "a" Then

Chr10.Text = "A"

End If

If str(1) = "a" Then

Chr9.Text = "A"

End If

If str(2) = "a" Then

Chr8.Text = "A"

End If

If str(3) = "a" Then

Chr7.Text = "A"

End If

If str(4) = "a" Then

Chr6.Text = "A"

End If

If str(5) = "a" Then

Chr5.Text = "A"

End If

If str(6) = "a" Then

Chr4.Text = "A"

End If

If str(7) = "a" Then

Chr3.Text = "A"

End If

If str(8) = "a" Then

Chr2.Text = "A"

End If

If str(9) = "a" Then

Chr1.Text = "A"

End If

ElseIf Word_in.TextLength = 11 Then

If str(0) = "a" Then

Chr11.Text = "A"

End If

If str(1) = "a" Then

Chr10.Text = "A"

End If

If str(2) = "a" Then

Chr9.Text = "A"

End If

If str(3) = "a" Then

Chr8.Text = "A"

End If

If str(4) = "a" Then

Chr7.Text = "A"

End If

If str(5) = "a" Then

Chr6.Text = "A"

End If

If str(6) = "a" Then

Chr5.Text = "A"

End If

If str(7) = "a" Then

Chr4.Text = "A"

End If

If str(8) = "a" Then

Chr3.Text = "A"

End If

If str(9) = "a" Then

Chr2.Text = "A"

End If

If str(10) = "a" Then

Chr1.Text = "A"

End If

ElseIf Word_in.TextLength = 12 Then

If str(0) = "a" Then

Chr12.Text = "A"

End If

If str(1) = "a" Then

Chr11.Text = "A"

End If

If str(2) = "a" Then

Chr10.Text = "A"

End If

If str(3) = "a" Then

Chr9.Text = "A"

End If

If str(4) = "a" Then

Chr8.Text = "A"

End If

If str(5) = "a" Then

Chr7.Text = "A"

End If

If str(6) = "a" Then

Chr6.Text = "A"

End If

If str(7) = "a" Then

Chr5.Text = "A"

End If

If str(8) = "a" Then

Chr4.Text = "A"

End If

If str(9) = "a" Then

Chr3.Text = "A"

End If

If str(10) = "a" Then

Chr2.Text = "A"

End If

If str(11) = "a" Then

Chr1.Text = "A"

End If

Перейти на страницу:

Похожие книги