You are on page 1of 1

'Project: name manipulation

'Purpose: illustrates use of string manipulation


' asks user for first, middle, and last name and divides the n
ame using string manipulation
'Created by: Jesse Bonds on 2/4/13
Option Strict On
Option Explicit On
Option Infer Off
Public Class mainForm
Private Sub exitButton_Click(sender As System.Object, e As System.EventArgs)
Handles exitButton.Click
Close()
End Sub
Private Sub resetButton_Click(sender As System.Object, e As System.EventArgs
) Handles resetButton.Click
firstLabel.ResetText()
middleLabel.ResetText()
lastLabel.ResetText()
enterButton.Focus()
End Sub
Private Sub enterButton_Click(sender As System.Object, e As System.EventArgs
) Handles enterButton.Click
Dim userName As String = InputBox("Enter your first, middle, and last na
me", "NAME")
Dim first, middle, last As String
Dim indx, lastspace As Integer
indx = userName.IndexOf(" ")
first = userName.Substring(0, indx)
firstLabel.Text = first
middle = userName.Substring(indx + 1)
middleLabel.Text = middle
lastspace = middleLabel.Text.Length
last = userName.Substring(lastspace)
lastLabel.Text = last
End Sub

Private Sub mainForm_Load(sender As System.Object, e As System.EventArgs) Ha
ndles MyBase.Load
End Sub
End Class

You might also like