(Visual Basic)
假设我有一个字符串,其中包含以下内容:
72 101 108 108 111 32 33
问题是,我如何循环通过那些(制表符分隔的)数字,以便将每个数字转换为它所代表的CHAR值(在这种情况下,它是“Hello!”)。
答案 0 :(得分:0)
尝试这样的事情:
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