我遇到了我分配給Visual Basic 2012課程的問題。說明如下。到目前爲止,我只顯示輸入的名字,沒有別的。我怎樣才能讓它顯示所請求的序列中的名字和姓氏?如何使用字符串以不同順序顯示名稱?
String問題:在文本框中輸入您的名字和姓氏。取名稱並將其顯示在顯示姓氏,名字的標籤框中。
文本框輸入:李四
標籤框:DOE,簡
我到目前爲止的代碼如下。謝謝你的幫助!
Private Sub btndisplay_Click(sender As Object, e As EventArgs) Handles btndisplay.Click
Dim fullname As String
Dim firstname As String
Dim indexnum As Integer
Dim lastname As String
fullname = fulltextbox.Text
indexnum = fullname.IndexOf(" ")
firstname = fullname.Substring(0, indexnum)
firstlabel.Text = firstname
fulltextbox.Focus()
End Sub
Private Sub fulltextbox_TextChanged(sender As Object, e As EventArgs)
firstlabel.Text = String.Empty
fulltextbox.SelectAll()
End Sub
Private Sub btnexit_Click(sender As Object, e As EventArgs) Handles btnexit.Click
Me.Close()
End Sub
單擊按鈕時標籤是否應該更改? –