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

📄 config.frm

📁 16路舵机控制程序。可以同时控制16个舵机
💻 FRM
字号:
VERSION 5.00
Begin VB.Form config 
   BackColor       =   &H00E0E0E0&
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "设置参数"
   ClientHeight    =   3510
   ClientLeft      =   4125
   ClientTop       =   3270
   ClientWidth     =   7185
   Icon            =   "config.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   3510
   ScaleWidth      =   7185
   ShowInTaskbar   =   0   'False
   Begin VB.Frame Frame1 
      BackColor       =   &H00E0E0E0&
      Caption         =   "串口设置"
      Height          =   2415
      Left            =   240
      TabIndex        =   2
      Top             =   240
      Width           =   6735
      Begin VB.TextBox time 
         Height          =   375
         Left            =   3480
         TabIndex        =   8
         Top             =   1680
         Width           =   2535
      End
      Begin VB.TextBox setting 
         Height          =   375
         Left            =   3480
         TabIndex        =   6
         Top             =   1080
         Width           =   2535
      End
      Begin VB.TextBox Port 
         Height          =   375
         Left            =   3480
         TabIndex        =   4
         Top             =   480
         Width           =   2535
      End
      Begin VB.Label Label4 
         BackColor       =   &H00E0E0E0&
         Caption         =   "ms/步"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9.75
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   6120
         TabIndex        =   9
         Top             =   1800
         Width           =   1095
      End
      Begin VB.Label Label3 
         BackColor       =   &H00E0E0E0&
         Caption         =   "发送时间间隔(毫秒)"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9.75
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   120
         TabIndex        =   7
         Top             =   1800
         Width           =   3135
      End
      Begin VB.Label Label2 
         BackColor       =   &H00E0E0E0&
         Caption         =   "波特率,奇偶校验,数据位,停止位"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9.75
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   495
         Index           =   0
         Left            =   120
         TabIndex        =   5
         Top             =   1080
         Width           =   4215
      End
      Begin VB.Label Label1 
         BackColor       =   &H00E0E0E0&
         Caption         =   "选择串口(1,2,3,4)"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   9.75
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   120
         TabIndex        =   3
         Top             =   480
         Width           =   2415
      End
   End
   Begin VB.CommandButton cancel 
      Caption         =   "取消"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   4440
      TabIndex        =   1
      Top             =   2880
      Width           =   1095
   End
   Begin VB.CommandButton ok 
      Caption         =   "确定"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   9.75
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   1680
      TabIndex        =   0
      Top             =   2880
      Width           =   1095
   End
End
Attribute VB_Name = "config"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False



Private Sub cancel_Click()
    
    
    Pause = PauseCopy
    frmServo.PauseCom.Visible = True
    
    config.Hide
    Unload config

End Sub

Private Sub ok_Click()
        
    On Error GoTo SettingError
    
    Pause = PauseCopy
    frmServo.PauseCom.Visible = True
    
    
    
    '若串口已经打开,则关闭。设置串口参数时,要确保串口关闭。
    If frmServo.ctrMSComm.PortOpen = True Then
    
        frmServo.ctrMSComm.PortOpen = False
        
    End If
    
              
    intPort = Val(Trim(config.Port.Text))
    strSet = Trim(config.setting.Text)
    intTime = Val(Trim(config.time.Text))
    
    '设置串口号和通信参数
    frmServo.ctrMSComm.CommPort = intPort
    frmServo.ctrMSComm.Settings = strSet
    
    
    '若串口还没有打开,则打开
    If frmServo.ctrMSComm.PortOpen = False Then
    
        frmServo.ctrMSComm.PortOpen = True

    End If
    
    
    config.Hide
    Unload config
    
    Exit Sub
    
    
    
    '设置出错处理:错误提示,进行重设
SettingError:
    intPort = 1
    intTime = 1000
    strSet = "9600,N,8,1"
    
    config.Show
    config.Port.Text = Str(intPort)
    config.setting.Text = strSet
    config.time.Text = Str(intTime)
    
    MsgBox (Error(Err.Number))
    
    
End Sub


⌨️ 快捷键说明

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