VB中关于调用子程序的问题
PrivateSubTimer1_Timer()Dimbuffer$'SendGetAIcommandtoADAM-4011Moduleataddress01H.MSCo...
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
怎样调用下面的子程序? 展开
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
怎样调用下面的子程序? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询