⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modtst1.frm

📁 Conexion de Modbus rs485
💻 FRM
字号:
VERSION 5.00
Begin VB.Form ModComTest 
   Caption         =   "ModCom Test Application"
   ClientHeight    =   4710
   ClientLeft      =   3090
   ClientTop       =   420
   ClientWidth     =   8970
   LinkTopic       =   "Form1"
   ScaleHeight     =   4710
   ScaleWidth      =   8970
   Begin VB.Frame Frame4 
      Caption         =   "Modem Commands"
      Height          =   3435
      Left            =   1110
      TabIndex        =   1
      Top             =   270
      Width           =   5865
      Begin VB.TextBox Text23 
         Height          =   375
         Left            =   1530
         TabIndex        =   11
         Top             =   2130
         Width           =   1215
      End
      Begin VB.TextBox Text24 
         Height          =   405
         Left            =   1530
         TabIndex        =   10
         Top             =   2640
         Width           =   4095
      End
      Begin VB.TextBox Text6 
         Height          =   315
         Left            =   1530
         TabIndex        =   6
         Text            =   "299-793"
         Top             =   240
         Width           =   1245
      End
      Begin VB.Timer Timer1 
         Enabled         =   0   'False
         Interval        =   500
         Left            =   3210
         Top             =   390
      End
      Begin VB.TextBox Text1 
         Height          =   975
         Left            =   1530
         MultiLine       =   -1  'True
         TabIndex        =   5
         Top             =   960
         Width           =   2865
      End
      Begin VB.CommandButton Command5 
         Caption         =   "START Timer Read Modem Receive Data"
         Height          =   735
         Left            =   90
         TabIndex        =   4
         Top             =   960
         Visible         =   0   'False
         Width           =   1260
      End
      Begin VB.CommandButton Command1 
         Caption         =   "DTR OFF / Disconnect"
         Height          =   525
         Left            =   120
         TabIndex        =   3
         Top             =   1950
         Width           =   1260
      End
      Begin VB.CommandButton Command2 
         Caption         =   "Send AT dial string"
         Height          =   525
         Left            =   105
         TabIndex        =   2
         Top             =   315
         Width           =   1260
      End
   End
   Begin VB.Frame Frame3 
      Caption         =   "Misc"
      Height          =   2415
      Left            =   7290
      TabIndex        =   0
      Top             =   210
      Width           =   855
      Begin VB.CommandButton Command16 
         Caption         =   "Reset busy"
         Height          =   465
         Left            =   90
         TabIndex        =   9
         Top             =   270
         Width           =   645
      End
      Begin VB.CommandButton Command14 
         Caption         =   "Clear resp label"
         Height          =   645
         Left            =   90
         TabIndex        =   8
         Top             =   840
         Width           =   645
      End
      Begin VB.CommandButton Command10 
         Caption         =   "Clear port"
         Height          =   465
         Left            =   90
         TabIndex        =   7
         Top             =   1725
         Width           =   645
      End
   End
End
Attribute VB_Name = "ModComTest"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Use this form as template for ModBus communications

Private Sub Command1_Click()
  
'do this to disconnect modem

ModComSimple.ModCom1.DTREnable = False
End Sub

Private Sub Command10_Click()
'clears comm buffer
  ModComSimple.ModCom1.ClearCommPort
  
End Sub





Private Sub Command14_Click()
  Label1 = ""
  Label2 = ""
  
End Sub


Private Sub Command16_Click()
'clear any PLC comm errors
ModComSimple.ModCom1.CommBusy = False
End Sub



Private Sub Command2_Click()

'send AT string to Modem through comm port
ModComSimple.ModCom1.SendToComm "ATDT" + Text6 + vbCr

'ModComSimple.ModCom1.SendToComm "ATDT299-7939" + vbCr



End Sub


Private Sub Command5_Click()
 
'start timer to
 'read whatever is being rec on comm line,
 'use to monitor modem connect state
 
 
 Text1 = ""
 
If Timer1.Enabled = False Then
  Command5.Caption = "STOP Timer"
  Timer1.Enabled = True
Else

 Command5.Caption = "START Timer Read Modem Receive Data"
  Timer1.Enabled = False
End If

End Sub

Private Sub Command7_Click()

'use this to force internal addressed buffer data to value
'if no PLC connection
'or to transfer data from other source to database buffer

Dim address As Variant
Dim Value(10) As Long

address = Text21
Value(1) = Text4

  DB1.WriteToDatabase address, Value
  
End Sub



Private Sub Form_Load()

'ModComSimple.ModCom1.CommPort = Text10
'ModComSimple.ModCom1.PortOpen = True


End Sub



Private Sub Timer1_Timer()

 'read whatever is being rec on comm line,
 'use to monitor modem connect state

Dim ByteArr() As Byte
 Dim rec As Variant
   
   
   
   'rec1$ = ModComSimple.ModCom1.ReceiveComm
 
   rec = ModComSimple.ModCom1.ReceiveComm
   If Len(rec) > 0 Then
'  If rec <> "" Then
      ByteArr() = rec
       For i% = 0 To (Len(rec) * 2) - 1
       Drec$ = Drec$ + Chr$(ByteArr(i%))
  Next i%
  
  Text1 = Drec$
  
  End If
  

End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -