Private Sub Timer1_Timer()
Dim buffer$
' Send Get AI command to ADAM-4011 Module at address 01H.
MSComm1.Output = "$016" & Chr$(13)
' Wait for data to come back to the serial port.
Do
DoEvents
buffer$ = buffer$ & MSComm1.Input
Loop Until InStr(buffer$, vbCr)
' Read the response till the carriage return character.
Text1.Text = buffer$' Display the reading.
databit$ = Mid(databit$, 5, 1)
End Sub怎样在上面调用下面的这个子程序?Public Function H2B(ByVal Hex As String) As String
Dim i As Long
Dim b As String
i = databit$
Hex = UCase(Hex)
For i = 1 To Len(Hex)
Select Case Mid(Hex, i, 1)
Case "0": b = b & "0000"
Case "1": b = b & "0001"
Case "2": b = b & "0010"
Case "3": b = b & "0011"
Case "4": b = b & "0100"
Case "5": b = b & "0101"
Case "6": b = b & "0110"
Case "7": b = b & "0111"
Case "8": b = b & "1000"
Case "9": b = b & "1001"
Case "A": b = b & "1010"
Case "B": b = b & "1011"
Case "C": b = b & "1100"
Case "D": b = b & "1101"
Case "E": b = b & "1110"
Case "F": b = b & "1111"
End Select
Next i
While Left(b, 1) = "0"
b = Right(b, Len(b) - 1)
Wend
H2B = b
Text2.Text = b
End Function
怎样调用下面的子程序?
VB中关于调用子程序的问题
答案:2 悬赏:80 手机版
解决时间 2021-02-11 16:52
- 提问者网友:川水往事
- 2021-02-10 23:29
最佳答案
- 五星知识达人网友:等灯
- 2021-02-10 23:58
你这是函数,不是子程序
调用方式和系统函数一样
aa="abdec"
bb=H2B(aa)
调用方式和系统函数一样
aa="abdec"
bb=H2B(aa)
全部回答
- 1楼网友:第幾種人
- 2021-02-11 00:33
你恰好犯了一个错误。
既然你没有用函数的形式来返回值,而试图通过过程参数的方式来取得返回值,那么这个参数就不能按值来传递,要按引用来传递(c语言的指针)。故你的过程要这样定义:
private sub maxlength(byval s as string, byref maxword as string)
而且最好事先给变量maxword1赋一定的长度值,例如
maxword1 = " "
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯