(Visual Basic)
假设我有一个包含例如以下内容的字符串:
72 101 108 108 111 32 33
问题是,我如何循环遍历这些(制表符分隔的)数字,以便将每个数字转换为它所代表的 CHAR 值(在这种情况下,它是“你好!”)。
尝试这样的事情:
Imports System.Text
Module Module1
Sub Main()
' Your initial input string
Dim x As String = "72" & vbTab & "101" & vbTab & "108" & vbTab & "108" & vbTab & "111" & vbTab & "32" & vbTab & "33"
' The object that will store your final word
Dim FinalWord As New stringbuilder
' Loop through your input string and convert each ASCII code to a character
For Each Code As String In x.Split(vbTab)
FinalWord.Append(Chr(CInt(Code)))
Next
'..... Do whatever you wnat with your "FinalWord"
End Sub
End Module