Zebra0.com

visual-basic examplesProfessor Joy: CA125 Class Work

Professor Joy: CA125 Class Work

Class Work Week 9

Input name as Last,First Split into last and first if there is a comma.
Public Class Form1
    Private Sub TxtName_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtName.KeyPress
        If e.KeyChar.Equals(Chr(13)) Then
            Dim S As String = TxtName.Text
            Dim Comma As Integer = S.IndexOf(",")
            If Comma < 0 Then
                MsgBox("Name must have a comma!", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "ERROR")
            Else
                Dim Last As String = S.Substring(0, Comma)
                Dim First As String = S.Substring(Comma + 1)
                Me.Text = First & " " & Last
            End If
        End If
    End Sub
End Class

This web site, and all pages therein, are the sole property and responsibility of Zebra0.com.
It is not endorsed, sponsored, or provided by or on behalf of Montgomery College.