www.pudn.com > ModBusUtility.rar > frmCOM.frm


VERSION 5.00 
Begin VB.Form frmCOM  
   BorderStyle     =   3  'Fixed Dialog 
   Caption         =   "端口设置" 
   ClientHeight    =   2040 
   ClientLeft      =   45 
   ClientTop       =   435 
   ClientWidth     =   5070 
   Icon            =   "frmCOM.frx":0000 
   LinkTopic       =   "Form1" 
   LockControls    =   -1  'True 
   MaxButton       =   0   'False 
   MinButton       =   0   'False 
   ScaleHeight     =   2040 
   ScaleWidth      =   5070 
   ShowInTaskbar   =   0   'False 
   StartUpPosition =   2  '屏幕中心 
   Begin VB.CommandButton cmdSet  
      Caption         =   "设   定" 
      Height          =   405 
      Left            =   2880 
      TabIndex        =   10 
      Top             =   1320 
      Width           =   1815 
   End 
   Begin VB.ComboBox cmbStop  
      Height          =   300 
      Left            =   1170 
      Style           =   2  'Dropdown List 
      TabIndex        =   9 
      Top             =   1380 
      Width           =   1065 
   End 
   Begin VB.ComboBox cmbSJW  
      Height          =   300 
      Left            =   3645 
      Style           =   2  'Dropdown List 
      TabIndex        =   8 
      Top             =   825 
      Width           =   1065 
   End 
   Begin VB.ComboBox cmbXYW  
      Height          =   300 
      Left            =   1170 
      Style           =   2  'Dropdown List 
      TabIndex        =   7 
      Top             =   825 
      Width           =   1065 
   End 
   Begin VB.ComboBox cmbBit  
      Height          =   300 
      Left            =   3645 
      Style           =   2  'Dropdown List 
      TabIndex        =   6 
      Top             =   285 
      Width           =   1065 
   End 
   Begin VB.ComboBox cmbCOM  
      Height          =   300 
      Left            =   1170 
      Style           =   2  'Dropdown List 
      TabIndex        =   5 
      Top             =   285 
      Width           =   1065 
   End 
   Begin VB.Label Label  
      BackColor       =   &H008080FF& 
      BackStyle       =   0  'Transparent 
      Caption         =   "停止位:" 
      Height          =   180 
      Index           =   4 
      Left            =   420 
      TabIndex        =   4 
      Top             =   1425 
      Width           =   735 
   End 
   Begin VB.Label Label  
      BackColor       =   &H008080FF& 
      BackStyle       =   0  'Transparent 
      Caption         =   "数据位:" 
      Height          =   180 
      Index           =   3 
      Left            =   2895 
      TabIndex        =   3 
      Top             =   870 
      Width           =   735 
   End 
   Begin VB.Label Label  
      BackColor       =   &H008080FF& 
      BackStyle       =   0  'Transparent 
      Caption         =   "校验位:" 
      Height          =   180 
      Index           =   2 
      Left            =   420 
      TabIndex        =   2 
      Top             =   870 
      Width           =   735 
   End 
   Begin VB.Label Label  
      BackColor       =   &H008080FF& 
      BackStyle       =   0  'Transparent 
      Caption         =   "波特率:" 
      Height          =   180 
      Index           =   1 
      Left            =   2895 
      TabIndex        =   1 
      Top             =   345 
      Width           =   735 
   End 
   Begin VB.Label Label  
      BackColor       =   &H008080FF& 
      BackStyle       =   0  'Transparent 
      Caption         =   "端口号:" 
      Height          =   180 
      Index           =   0 
      Left            =   420 
      TabIndex        =   0 
      Top             =   345 
      Width           =   735 
   End 
End 
Attribute VB_Name = "frmCOM" 
Attribute VB_GlobalNameSpace = False 
Attribute VB_Creatable = False 
Attribute VB_PredeclaredId = True 
Attribute VB_Exposed = False 
Option Explicit 
Private Sub cmdSet_Click() 
  xCOM = Right$(cmbCOM.Text, 1) 
'  ComSetting = "9600,N,8,1" 
  ComSetting = cmbBit.Text & "," & Mid$(cmbXYW.Text, 2, 1) & "," & cmbSJW.Text & "," & cmbStop.Text 
'  Debug.Print ComSetting 
  frmUtility.lblComsettings = "COM:" & xCOM & Space(2) & "Settings:" & ComSetting 
  Unload Me 
End Sub 
Private Sub Form_Load() 
  Dim i As Long 
  Dim Pointx As Integer 
 
  For i = 1 To 9 
      cmbCOM.AddItem ("COM" & i) 
  Next i 
  For i = 0 To 8 
      If Right$(cmbCOM.List(i), 1) = xCOM Then 
         cmbCOM.Text = cmbCOM.List(i) 
         Exit For 
      End If 
  Next i 
'  ----------------------------- 
  cmbBit.AddItem ("110") 
  cmbBit.AddItem ("300") 
  cmbBit.AddItem ("600") 
  cmbBit.AddItem ("1200") 
  cmbBit.AddItem ("2400") 
  cmbBit.AddItem ("4800") 
  cmbBit.AddItem ("9600") 
  cmbBit.AddItem ("14400") 
  cmbBit.AddItem ("19200") 
  cmbBit.AddItem ("28800") 
  cmbBit.AddItem ("38400") 
  cmbBit.AddItem ("43000") 
  cmbBit.AddItem ("56000") 
  cmbBit.AddItem ("128000") 
  cmbBit.AddItem ("256000") 
  For i = 0 To 12 
      Pointx = InStr(1, ComSetting, ",") - 1 
      If Left$(ComSetting, Pointx) = cmbBit.List(i) Then 
         cmbBit.Text = cmbBit.List(i) 
         Exit For 
      End If 
  Next i 
'  ---------------------------- 
  cmbXYW.AddItem ("无None") 
  cmbXYW.AddItem ("奇Odd") 
  cmbXYW.AddItem ("偶Even") 
  For i = 0 To 2 
      If Mid$(ComSetting, Pointx + 2, 1) = Mid$(cmbXYW.List(i), 2, 1) Then 
         cmbXYW.Text = cmbXYW.List(i) 
         Exit For 
      End If 
  Next i 
'  ---------------------------- 
  cmbSJW.AddItem ("6") 
  cmbSJW.AddItem ("7") 
  cmbSJW.AddItem ("8") 
  For i = 0 To 2 
      If Mid$(ComSetting, Pointx + 4, 1) = cmbSJW.List(i) Then 
         cmbSJW.Text = cmbSJW.List(i) 
         Exit For 
      End If 
  Next i 
'  ---------------------------- 
  cmbStop.AddItem ("1") 
  cmbStop.AddItem ("2") 
  For i = 0 To 1 
      If Right$(ComSetting, 1) = cmbStop.List(i) Then 
         cmbStop.Text = cmbStop.List(i) 
         Exit For 
      End If 
  Next i 
End Sub 
 
Private Sub Form_Unload(Cancel As Integer) 
  frmCOMopen = False 
  Set frmCOM = Nothing 
'  Debug.Print frmCOMopen 
End Sub