?? frmcounter.frm
字號:
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 25
Top = 1560
Width = 1335
End
Begin VB.Label Label7
Caption = "Overflow"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 240
TabIndex = 31
Top = 1080
Width = 855
End
Begin VB.Label Label9
Caption = "Counter Value"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 2040
TabIndex = 29
Top = 1080
Width = 1215
End
Begin VB.Label Label6
Caption = "Channel Index"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 240
Left = 240
TabIndex = 28
Top = 480
Width = 1320
End
End
Begin VB.Frame Frame1
Caption = "Step 1: Open COM Port"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 1575
Left = 30
TabIndex = 1
Top = 60
Width = 4185
Begin VB.CommandButton cmdClose
Caption = "Close COM"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 2280
TabIndex = 21
Top = 960
Width = 1455
End
Begin VB.CommandButton cmdOpen
Caption = "Open COM Port"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Left = 240
TabIndex = 6
Top = 945
Width = 1665
End
Begin VB.TextBox txtPort
Height = 330
Left = 990
TabIndex = 3
Text = "1"
Top = 450
Width = 570
End
Begin VB.TextBox txtBaudrate
Height = 390
Left = 2805
TabIndex = 2
Text = "9600"
Top = 420
Width = 960
End
Begin VB.Label Label1
Caption = "COM Port"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 90
TabIndex = 5
Top = 480
Width = 810
End
Begin VB.Label Label2
Caption = "BaudRate"
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 270
Left = 1830
TabIndex = 4
Top = 510
Width = 825
End
End
Begin VB.CommandButton cmdExit
Caption = "Exit"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 450
Left = 3480
TabIndex = 0
Top = 3960
Width = 1725
End
End
Attribute VB_Name = "frmCounter"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim iPort As Integer
Dim iCheckSum As Integer
Dim iTimeOut As Integer
Dim lBaudrate As Long
Private Sub cmdClose_Click()
Me.Caption = " COM " + Str(iPort) + " Closed !"
Close_Com (iPort)
End Sub
Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub cmdOpen_Click()
Dim iRet As Integer
iPort = CInt(txtPort.Text)
lBaudrate = CLng(txtBaudrate.Text)
iRet = Open_Com(iPort, lBaudrate, 8, 0, 0)
If iRet Then
MsgBox "Open COM Port Error:" + Str(iRet), vbCritical, "Open COM"
Else
Me.Caption = " COM " + Str(iPort) + " Opened !"
End If
End Sub
Private Sub cmdRead_Click()
Dim iRet As Integer
Dim lCounter As Long
Dim DOVal As Long
Dim iSlot As Integer
Dim iTotal As Integer
Dim iChIndex As Integer
Dim iAddress As Integer
Dim lOverflow As Long
iAddress = CInt(txtAddress.Text)
If optCheck(0).Value = True Then
iCheckSum = 0
Else
iCheckSum = 1
End If
iTimeOut = CInt(txtTimeout.Text)
If optModule(0).Value = True Then
iSlot = -1
Else
iSlot = CInt(txtSlot.Text)
End If
iTotal = CInt(txtTotal.Text)
iChIndex = CInt(txtCh.Text)
iRet = DCON_Read_Counter(iPort, iAddress, iSlot, iChIndex, iCheckSum, iTimeOut, lCounter)
If iRet = 0 Then
txtCounter.Text = Str(lCounter)
Else
txtCounter.Text = "Error" & Str(iRet)
End If
iRet = DCON_Read_Overflow(iPort, iAddress, iSlot, iChIndex, iCheckSum, iTimeOut, lOverflow)
If iRet = 0 Then
txtOverflow.Text = Str(lOverflow)
Else
txtOverflow.Text = "Error" & Str(iRet)
End If
End Sub
Private Sub cmdWrite_Click()
Dim iRet As Integer
Dim iSlot As Integer
Dim iTotalDI As Integer
Dim iChIndex As Integer
Dim iAddress As Integer
iAddress = CInt(txtAddress.Text)
If optCheck(0).Value = True Then
iCheckSum = 0
Else
iCheckSum = 1
End If
iTimeOut = CInt(txtTimeout.Text)
If optModule(0).Value = True Then
iSlot = -1
Else
iSlot = CInt(txtSlot.Text)
End If
iChIndex = CInt(txtCh.Text)
iRet = DCON_Clear_Counter(iPort, iAddress, iSlot, iChIndex, iCheckSum, iTimeOut)
If iRet Then
MsgBox "Error Code" & Str(iRet), vbCritical, "Error"
End If
End Sub
Private Sub Form_Load()
If optModule(0).Value = True Then
txtSlot.Enabled = False
txtSlot.Text = "-1"
Else
txtSlot.Enabled = True
txtSlot.Text = "0"
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Close_Com (iPort)
End Sub
Private Sub optModule_Click(Index As Integer)
If Index = 0 Then
txtSlot.Enabled = False
txtSlot.Text = "-1"
Else
txtSlot.Enabled = True
txtSlot.Text = "0"
End If
End Sub
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -