VERSION 5.00
Object = "{FE0065C0-1B7B-11CF-9D53-00AA003C9CB6}#1.1#0"; "COMCT232.OCX"
Begin VB.Form frmConfig 
   Caption         =   "配置"
   ClientHeight    =   2175
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   3165
   Icon            =   "frmConfig.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   2175
   ScaleWidth      =   3165
   StartUpPosition =   3  '窗口缺省
   Begin ComCtl2.UpDown UpDown1 
      Height          =   270
      Left            =   2430
      TabIndex        =   8
      Top             =   720
      Width           =   315
      _ExtentX        =   423
      _ExtentY        =   476
      _Version        =   327681
      BuddyControl    =   "Text1"
      BuddyDispid     =   196610
      OrigLeft        =   2400
      OrigTop         =   720
      OrigRight       =   2715
      OrigBottom      =   975
      Max             =   255
      SyncBuddy       =   -1  'True
      BuddyProperty   =   65547
      Enabled         =   -1  'True
   End
   Begin VB.ComboBox Cbospeed 
      Height          =   300
      Left            =   1800
      Style           =   2  'Dropdown List
      TabIndex        =   7
      Top             =   1080
      Width           =   855
   End
   Begin VB.TextBox Text1 
      Alignment       =   1  'Right Justify
      Height          =   270
      Left            =   1800
      TabIndex        =   6
      Top             =   720
      Width           =   615
   End
   Begin VB.CommandButton Command2 
      Caption         =   "取消"
      Height          =   375
      Left            =   1800
      TabIndex        =   4
      Top             =   1560
      Width           =   735
   End
   Begin VB.CommandButton Command1 
      Caption         =   "确定"
      Height          =   375
      Left            =   480
      TabIndex        =   3
      Top             =   1560
      Width           =   735
   End
   Begin VB.Label Label2 
      AutoSize        =   -1  'True
      Caption         =   "Label2"
      ForeColor       =   &H0000FFFF&
      Height          =   180
      Left            =   1800
      TabIndex        =   5
      Top             =   360
      Width           =   540
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "波特率："
      Height          =   180
      Index           =   2
      Left            =   480
      TabIndex        =   2
      Top             =   1080
      Width           =   720
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "地址[十进制]："
      Height          =   180
      Index           =   1
      Left            =   480
      TabIndex        =   1
      Top             =   720
      Width           =   1260
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "模块："
      Height          =   180
      Index           =   0
      Left            =   480
      TabIndex        =   0
      Top             =   360
      Width           =   540
   End
End
Attribute VB_Name = "frmConfig"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim str As String
Dim strS As String
Dim oldAddress As String

Private Sub Command1_Click()
   Dim band As Integer
   Dim ys As Single
   modAddress = Val(Text1)
   band = Cbospeed.ListIndex + 3
   str = "%" + Right("0" + Hex(oldAddress), 2) + Right("0" + Hex(modAddress), 2) _
          + "00" + "0" + Format(band) + "01" + Chr(13)
   ys = Timer + 0.1
   frmComm.MSComm1.Output = str
   ys = Timer + 0.1
   Do
      DoEvents
      If frmComm.MSComm1.InBufferCount >= 4 Then
         Exit Do
      End If
   Loop Until Timer > ys
   strS = frmComm.MSComm1.Input
   If Left(strS, 1) = "!" And Right(strS, 1) = Chr(13) Then
      MsgBox "模块配置成功!", vbInformation + vbOKOnly, "成功!"
   Else
      MsgBox "模块配置失败!", vbCritical + vbOKOnly, "失败!"
   End If
   frmComm.Enabled = True
   Unload Me
   frmComm.xxx
End Sub

Private Sub Command2_Click()
   frmComm.Enabled = True
   Unload Me
End Sub

Private Sub Form_Load()
   Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
   Label2 = "CE-" + modName
   Text1 = modAddress
   oldAddress = modAddress
   UpDown1.Value = modAddress
   Cbospeed.AddItem "1200"
   Cbospeed.AddItem "2400"
   Cbospeed.AddItem "4800"
   Cbospeed.AddItem "9600"
   Cbospeed.AddItem "19200"
   Cbospeed.Text = "9600"
End Sub


