Home > Back-end >  Please can help change the Vb code to DELPHI code, thank you!
Please can help change the Vb code to DELPHI code, thank you!

Time:04-22

Option Explicit
Dim qq As Integer

Private Sub Command1_Click ()
If Command1. Caption="OPEN" Then
If MSComm1. PortOpen=True Then MSComm1. PortOpen=False
MSComm1.Com mPort=CInt (Combo1. Text)
Timer1. Enabled=True
Command1. Caption="CLOSE"
The Else
Timer1. Enabled=False
Command1. Caption="OPEN"
Qq=0
Label1. Caption=CStr (qq)
End the If
End Sub

Private Sub Form_Load ()
Combo1. ListIndex=7
Combo2. ListIndex=0
Qq=0
End Sub


Private Sub Timer1_Timer ()
Dim Outadress (0) As Byte
Dim OutData (6) As Byte


Timer1. Enabled=False

If MSComm1. PortOpen=True Then
MSComm1. PortOpen=False
MSComm1. PortOpen=True
The Else: MSComm1 PortOpen=True
End the If

'MSComm1. Settings="9600, m, 8, 1", "

Outadress (0)=StrConv (CInt (Combo2. Text), vbFromUnicode)

'MSComm1. InputLen=0
'MSComm1. InBufferCount=0
'MSComm1. OutBufferCount=0
MSComm1. The Output=Outadress

'Pausett
Label2. ForeColor=& amp; HFE
MSComm1. Settings="9600, s, 8, 1", "
OutData (0)=2
OutData (1)=254 '& amp; HFE
OutData (2)=0
OutData (3)=0
OutData (4)=0
OutData (5)=0
OutData (6)=1 'StrConv (CInt (Combo2. Text), vbFromUnicode)
Text5. Text=OutData (1)
MSComm1. RThreshold=92
MSComm1. InputLen=0
MSComm1. InBufferCount=0
MSComm1. OutBufferCount=0
MSComm1. The Output=OutData

Qq=qq + 1
Label1. Caption=CStr (qq)

Timer1. Enabled=True
End Sub

Private Sub MSComm1_OnComm ()
Dim InBuffer
Dim As Integer I
As a Double Dim a, b As an Integer, iSign As Integer
Dim iCrc As Integer


If MSComm1.Com mEvent=comEvReceive Then
InBuffer=MSComm1. Input

For I=0 To 90
If IsNumeric (InBuffer (I))=True Then
DoEvents

The iCrc=iCrc + InBuffer (I)
Text4. Text=iCrc
End the If
Next

ICrc=iCrc Mod 256
If the iCrc=InBuffer (91) Then

If InBuffer (15) & gt; Then 127
ISign=1
InBuffer (15)=InBuffer (15) - 128
The Else
ISign=1
End the If
A=InBuffer (15) * 65536 * 256 + InBuffer (14) * 65536 + InBuffer (13) * 256 + InBuffer (12)
A=Int ((a + (InBuffer (11) * 256 + InBuffer (10))/65536) * 1000 * iSign + 0.5)/1000

Text1. Text=Format (a, "# 0.00")

If InBuffer (2) & gt; Then 127
ISign=1
InBuffer (2)=InBuffer (2) - 128
The Else
ISign=1
End the If
If InBuffer (3) & gt; Then 127
B=InBuffer (3) - 256
The Else
B=InBuffer (3)
End the If
A=InBuffer (2) * 65536 + InBuffer (1) * 256 + InBuffer (0)
A=a * 2 ^ (b - 23) * iSign
A=Int (a * 1000 + 0.5)/1000

Text2. Text=Format (a, "# 0.00")

ISign=IIf (InBuffer (82) & gt; 127, 1, 1)
If iSign=1 Then InBuffer (82)=InBuffer (82) - 128
B=IIf (InBuffer (83) & gt; 127, InBuffer (83) - 256, InBuffer (83))
A=InBuffer (82) * 2 ^ 16 + InBuffer (81) * 2 ^ 8 + InBuffer (80) * 2 ^ 0
A=a * 2 ^ (b - 23) * iSign

Text3. Text=Format (a, "# 0.00")
End the If
End the If


End Sub

Private Sub Pausett (Optional pInterval As Single=0.01)
Dim dt As Single, odt As Single
Dt=Timer: odt=dt
Do
Odt=Timer
If the odt & lt; Dt Then dt=odt
DoEvents
Loop While the odt & lt; Dt + pInterval
End Sub

CodePudding user response:

Scores can also add yo, trouble the warrior, be urgent! Be urgent! Be urgent!
  • Related