函数调用问题
我定义了一个字符串转换数组的函数,当调用函数时总是出现错误,请高手指点定义的字符串转换数组的函数string_hex(str as string) as byte,该函数通过验证没有问题
dim str1 as string
dim buf() as byte
redim buf(100)
buf=string_hex(str1)'该语句提示不能给数组赋值
'如果不采用上述语句,直接把转换的数组通过串口送出去
MSComm1.Output=string_hex(str1)'提示的错误是无效的属性值
我的目的是把字符串转换为数组通过串口发送出去
--------------------编程问答-------------------- MSComm1.Output=sendstr;
while MSComm1.Outbuffercount<>0 do --------------------编程问答-------------------- 贴上具体代码来 --------------------编程问答--------------------
把你的函数改一下更好用:
sub string_hex(str as string, buf() as byte)
dim str1 as string
dim buf() as byte
redim buf(100)
string_hex(str1, buf) --------------------编程问答--------------------
Private Sub Form_Load()
Dim a As String, c() As Byte
a = "nihao"
c = aaa(a)
End Sub
Function aaa(a As String) As Byte()
Dim b() As Byte
b = a
aaa = b
End Function
补充:VB , 基础类