0% found this document useful (0 votes)
35 views

Exercise 16

This code defines a class with a button click event handler that takes text from a text box, gets the first letter of the last word, converts it to lowercase, determines its position in the alphabet array, and uses that number to assign the text to one of three groups, displaying the group assignment on a label.

Uploaded by

api-308657631
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Exercise 16

This code defines a class with a button click event handler that takes text from a text box, gets the first letter of the last word, converts it to lowercase, determines its position in the alphabet array, and uses that number to assign the text to one of three groups, displaying the group assignment on a label.

Uploaded by

api-308657631
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles Button1.Click
Dim text As String() = TextBox1.Text.Split(" ")
Dim firstoflast As String = text(1).Substring(0, 1).ToLower
Dim alphabet As String() = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o",
"p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
Dim num As Integer = (Array.IndexOf(alphabet, firstoflast))

If num <= 8 Then


Label2.Text = TextBox1.Text + " is in Group 1!"
End If

If num > 8 And num <= 18 Then


Label2.Text = TextBox1.Text + " is in Group 2!"
End If

If num > 18 Then


Label2.Text = TextBox1.Text + " is in Group 3!"
End If

End Sub
End Class

You might also like