7,762
社区成员
发帖
与我相关
我的任务
分享
Private Sub Command1_Click()
Dim strCode As String
Dim strText As String
Dim i&, j&, k As Long
strCode = "有字符串CCED:欢迎回家17/1211"
i = InStr(1&, strCode, "&#")
If (0& = i) Then
strText = strCode
Else
strText = Left$(strCode, i - 1&)
Do
If (0& = i) Then
k = Len(strCode)
strText = strText & Mid$(strCode, 1& + j, k - j)
Exit Do
End If
j = InStr(i, strCode, ";")
strText = strText & ChrW$(Mid$(strCode, 2& + i, j - i - 2&))
i = InStr(j, strCode, "&#")
k = i - j
If (1& < k) Then strText = strText & Mid$(strCode, 1& + j, k - 1&)
Loop
End If
Call MsgBox(strText, 64, "转换结果")
End Sub
输出结果:
有字符串CCED:欢迎回家17/1211Private Sub Command1_Click()
Dim strCode As String
Dim strText As String
Dim i&, j As Long
strCode = "有字符串CCED:欢迎回家17/1211"
strText = "" ' 从“理论上说”这句是多余的
j = 1&
Do
i = InStr(j, strCode, "&#")
If (0& = i) Then Exit Do
j = InStr(i, strCode, ";")
If (0& = j) Then
strText = strText & ChrW$(Mid$(strCode, 2& + i))
Else
strText = strText & ChrW$(Mid$(strCode, 2& + i, j - i - 2&))
End If
Loop
Call MsgBox(strText, 64, "转换结果")
End Sub
那段编码的结果是: 欢迎回家