vb关于Function函数的调用

来源:百度知道 编辑:UC知道 时间:2024/05/08 15:00:02
Public Function chg(rmsg As String) As String
Dim tep As String
Dim temp As String
Dim i As Integer
Dim b As Integer
tep = rmsg
i = Len(tep)
b = i / 4
If i = b * 4 Then
b = b - 1
tep = Left(tep, b * 4)
Else
tep = Left(tep, b * 4)
End If
chg = ""
For i = 1 To b
temp = "&H" & Mid(tep, (i - 1) * 4 + 1, 4)
chg = chg & ChrW(CInt(Val(temp)))
Next i
End Function
我应该怎样才能在其他sub中用到返回值,比如在text中显示返回值
说的没错,可我用的时候得到的不是我想要的,这段代码是关于把中文转换为Unicode码,text里面怎么是空白阿,谢谢,如果能给我答复,我提高悬赏

哥们你那个算法有问题
For i = 1 To b 就这句 b = 0 循环不执行,当然是空白了
学程序要学会调试,你再检查一下算法

直接使用函数名就可以了
string = chg(参数值)

text1.text=chg(你要输入的值)