Dim myNum As Integer
Dim myAdress As Integer
Dim myCmd As String
Dim strMetIn As String
Dim strMetOut As String
Dim myCanal As Integer
Dim myReg As String
Dim NumAdress As Integer
Dim intCOM() As Integer
Dim nymCOM As Integer
Dim intSpeed(1 To 4) As Integer
Dim numSpeed As Integer
Dim myCOM As Integer
Dim N As Integer
Dim F As String
Private Sub closeCOM_Click()
MSComm1.PortOpen = False
Timer1.Enabled = False
Close
End Sub
Private Sub cmdRead_Click()
myCmd = "00"
strMetIn = Chr(Val(Str("&H" & myAdress))) & Chr(Val(Str(myCanal))) & Chr(Val("&H" & myReg)) & Chr(Val("&H" & myCmd))
Label1.Caption = Hex(Asc(myControlSum(strMetIn)))
strMetIn = strMetIn & myControlSum(strMetIn)
strMetOut = ""
Label3.Caption = ""
shpControlSum.FillColor = &HFF&
MSComm1.Output = strMetIn
End Sub
Private Sub Form_Load()
F = App.Path & "\1234." & "1234.txt"
'F = FreeFile
'Open "C:\massive.txt" For Append As #F
N = 1
'ReDim intCOM(N)
myNum = 3
myAdress = 2
myCanal = 0
myReg = "01"
NumAdress = 1
MSComm1.InputLen = 1
MSComm1.RThreshold = 1
nymCOM = 1
intSpeed(1) = 2400
intSpeed(2) = 4800
intSpeed(3) = 9600
intSpeed(4) = 19200
End Sub
Private Sub MSComm1_OnComm()
Dim strSymb As String
Select Case MSComm1.CommEvent
Case comEvReceive
strSymb = MSComm1.Input
strMetOut = strMetOut & strSymb
Label3.Caption = Label3.Caption & "/" & Hex(Asc(strSymb))
Label4.Caption = (Str(Len(strMetOut)))
If chekControlSum(strMetOut) = True Then
shpControlSum.FillColor = &HFF00&
Label4.Caption = "Г„Г*Г*Г*ûå:" & writeData(strMetOut) & vbCrLf _
& "Àäðåñ: " & Str(chekNumAdres(strMetOut)) & vbCrLf _
& "Íîìåð ГЄГ*Г*Г*Г«Г*: " & Str(chekNumKanal(strMetOut)) & vbCrLf _
& "ГђГҐГЈГЁГ±ГІГ°: " & chekRegAdres(strMetOut) & vbCrLf _
& "ÊîìГ*Г*Г¤Г*: " & chekComand(strMetOut) & vbCrLf _
& "Г’ГЁГЇ Г¤Г*Г*Г*ûõ: " & chekTypeData(strMetOut) & vbCrLf _
& "ÄëèГ*Г* Г¤Г*Г*Г*ûõ: " & chekLenData(strMetOut) & vbCrLf _
Else
Label4.Caption = ""
shpControlSum.FillColor = &HFF&
End If
End Select
End Sub
Private Sub opnCOM_Click()
Timer1.Enabled = True
MSComm1.CommPort = myNum
MSComm1.Settings = "9600, N, 8, 1"
MSComm1.PortOpen = True
End Sub
Private Sub Timer1_Timer()
myCmd = "00"
strMetIn = Chr(Val(Str("&H" & myAdress))) & Chr(Val(Str(myCanal))) & Chr(Val("&H" & myReg)) & Chr(Val("&H" & myCmd))
Label1.Caption = Hex(Asc(myControlSum(strMetIn)))
strMetIn = strMetIn & myControlSum(strMetIn)
strMetOut = ""
Label3.Caption = ""
shpControlSum.FillColor = &HFF&
MSComm1.Output = strMetIn
ReDim Preserve intCOM(N)
intCOM(N) = Val(strMetIn)
N = N + 1
Text1.Text = Text1.Text & Str(N)
Print #F, N
End Sub