111,126
社区成员
发帖
与我相关
我的任务
分享Private Declare Function OpenScalePort Lib "MySerial.dll" (ByVal ComPort As String, ByVal seting As String, ByVal fangshi As String) As Long
Private Declare Function ReadInstruments Lib "MySerial.dll" (ByVal yibiao As String) As String
Private Declare Function CloseScalePort Lib "MySerial.dll" () As Long
Private Declare Function YHa9ReadCode Lib "MySerial.dll" ()
Private Declare Function LoadCellReadData Lib "MySerial.dll" (ByVal LoadCellType As String, ByVal LoadCellNumber As Long, ByVal ntime As Long) As String
Private Sub Command1_Click()
If OpenScalePort(Combo2.Text, Text1.Text, Combo3.Text) = 1 Then
If Combo1.Text = "boast" Then
Timer2.Enabled = True
Else
Timer1.Enabled = True
End If
Command1.Enabled = False
Else
MsgBox "失败!", vbInformation + vbOKOnly, "提示"
End If
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
Timer2.Enabled = False
e = CloseScalePort
Command1.Enabled = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
e = CloseScalePort
End Sub
Private Sub Timer1_Timer()
Text2.Text = ReadInstruments(Combo1.Text)
End Sub
Private Sub Timer2_Timer()
DoEvents
Dim b As String
Dim LoadCellNumber As Integer
LoadCellNumber = 8
b = LoadCellReadData("boast", LoadCellNumber, 25)
Text2.Text = b
If Left(b, 1) = "S" Then
For i = 0 To LoadCellNumber - 1
Label1(i).Caption = Mid(b, 2 + i * 6, 6)
Next i
End If
End SubPrivate Declare Function OpenCom Lib "MyComm.dll" (ByVal ComPort As String, ByVal seting As String, ByVal fangshi As String) As Long
Private Declare Function YHScreen Lib "MyComm.dll" (ByVal bigscreenType as String ,ByVal b As Double) As Long
Private Declare Function CloseCom Lib "MyComm.dll" () As Long
Private Sub Command1_Click()
If OpenCom("com1", "600,n,8,1", "start") = 1 Then
Timer1.Enabled = True
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
e = CloseCom
End Sub
Private Sub Timer1_Timer()
DoEvents
e = YHScreen("abc",123456)
End Sub