設計一程式以下兩功能:
1.將輸入的英文字串保留英文及空白字元,其他字元均予刪除。例如"We *&^a^&*re98&^& the &_Be@#st" 轉換為 "We are the Best"
2.將輸入的英文字串字元反置。例如"We *&^a^&*re98&^& the &_Be@#st" 轉換為"ts#@eB_& eht &^&89er*&^a^&* eW"
參考物件佈放:
過濾字元
字元反置
參考程式碼(請完成空白部分)
Public
Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.
EventArgs) Handles Button1.Click
Dim str1 As String, str2 As String, num As Integer
str1 = TextBox1.Text
For i = 1 To '字串長度
Num = Asc(Mid(str1, i, 1)) '逐一取字元
If
Then '檢查否為英文或空格,使用ASC()函式(參考附表)________________________________ '將英文及空格串接
End If
Next
TextBox2.Text = str2 '顯示結果
End Sub
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim str1 As String, str2 As String
str1 = TextBox1.Text
For i = 1 To '字串長度
str2 &= _______________________ '字串反置串接
Next
TextBox2.Text = str2 '顯示結果
End Sub
End Class