我正在尝试制作一个翻译程序,其中英文字母的每个字母都将显示为一个组成的字母。
例如,当我在程序中写“a”时。程序将显示“akh”,如果我写“b”,它将显示“bil”。但是当我写“ab”或“ba”时,它只能写出两个中的一个。我该如何对其进行编码,以便按照我提供英文字符的顺序显示
这是代码:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs)
End Sub
Private Sub TextBox2_TextChanged(sender As Object, e As EventArgs) Handles TextBox2.TextChanged
End Sub
Private Sub TextBox3_TextChanged(sender As Object, e As EventArgs) Handles TextBox3.TextChanged
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim cerilian As String = Nothing
Dim englishtext As String = Nothing
englishtext = InputBox("Enter English Text")
If englishtext.Contains("a") Then
cerilian = "akh"
End If
If englishtext.Contains("b") Then
cerilian = "bil"
End If
TextBox2.Text = cerilian
End Sub
End Class
答案 0 :(得分:0)
试试这个:
Private map As New Dictionary(Of Char, String)() From _
{ _
{ "a"C, "akh" }, _
{ "b"C, "bil" } _
' etc
}
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim englishtext As String = InputBox("Enter English Text")
TextBox2.Text = String.Join("", _
englishtext.ToCharArray().Select(Function (x) map(x)))
End Sub