本人不是搞这个的,因为要做实验,需要测一个功率表的数据;下面这个是qb写得一个程序,能否改成vb?尤其是out那几句?或者可以改成vc?哪位大虾能帮一下忙啊? SCREEN 0 CLEAR OPEN "COM1:9600,n,8,1,RS,CS,DS,CD" FOR RANDOM AS #1 ON COM(1) GOSUB 3000 COM(1) OFF COM(1) ON
CLS ON KEY(1) GOSUB 500 KEY(1) ON LOCATE 1, 28: PRINT "--- Power Monitor System Test --- " LOCATE 2, 1: PRINT "F1: Get Data " 10
我试着改成如下的vb,但是运行时 无法启动MSComm1_OnComm()事件,为什么? Private Sub cmdTest_Click() MSComm1.CommPort = 2 'É趨Com2 If MSComm1.PortOpen = False Then MSComm1.Settings = "9600,n,8,1" MSComm1.PortOpen = True End If MSComm1.OutBufferCount = 0 MSComm1.InBufferCount = 0 Dim ByteArray(10) As Byte ByteArray(0) = &H2 ByteArray(1) = &H44 ByteArray(2) = &H47 ByteArray(3) = &H30 ByteArray(4) = &H30 ByteArray(5) = &H33 ByteArray(6) = &H31 ByteArray(7) = &H45 ByteArray(8) = &H3 ByteArray(9) = &HD
MSComm1.Output = ByteArray End Sub
Private Sub MSComm1_OnComm() Select Case MSComm1.CommEvent Case comEvReceive Dim Buffer As Variant MSComm1.InputLen = 0 MSComm1.InputMode = comInputModeBinary Buffer = MSComm1.Input MSComm1.InputMode = comInputModeText Buffer = MSComm1.Input Text1.Text = Buffer Case Else End Select End Sub