📄 firstcjy.frm
字号:
VERSION 5.00
Begin VB.Form firstcjy
BorderStyle = 4 'Fixed ToolWindow
Caption = "全站仪参数设置"
ClientHeight = 3600
ClientLeft = 45
ClientTop = 315
ClientWidth = 5640
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3600
ScaleWidth = 5640
ShowInTaskbar = 0 'False
StartUpPosition = 1 'CenterOwner
Begin VB.CommandButton Command2
Caption = "退 出"
Height = 525
Left = 4500
TabIndex = 4
Top = 2670
Width = 945
End
Begin VB.CommandButton Command1
Caption = "设 置"
Height = 525
Left = 3300
TabIndex = 3
Top = 2670
Width = 945
End
Begin VB.Frame Frame3
Caption = "补偿器状态"
Height = 1125
Left = 60
TabIndex = 2
Top = 2400
Width = 2955
Begin VB.OptionButton Option2
Caption = "关闭"
Height = 285
Left = 1620
TabIndex = 9
Top = 450
Width = 975
End
Begin VB.OptionButton Option1
Caption = "打开"
Height = 315
Left = 360
TabIndex = 8
Top = 420
Value = -1 'True
Width = 1065
End
End
Begin VB.Frame Frame2
Caption = "波特率"
Height = 1125
Left = 60
TabIndex = 1
Top = 1215
Width = 2955
Begin VB.ComboBox Combo2
Height = 315
Left = 1020
Style = 2 'Dropdown List
TabIndex = 7
Top = 390
Width = 1665
End
Begin VB.Label Label2
Caption = "波特率:"
Height = 285
Left = 150
TabIndex = 6
Top = 420
Width = 885
End
End
Begin VB.Frame Frame1
Caption = "串行口"
Height = 1125
Left = 60
TabIndex = 0
Top = 30
Width = 2955
Begin VB.ComboBox Combo1
Height = 315
Left = 1020
Style = 2 'Dropdown List
TabIndex = 10
Top = 420
Width = 1635
End
Begin VB.Label Label1
Caption = "串口号:"
Height = 285
Left = 150
TabIndex = 5
Top = 450
Width = 885
End
End
Begin VB.Image Image1
Height = 1920
Left = 3750
Picture = "firstcjy.frx":0000
Top = 150
Width = 1290
End
End
Attribute VB_Name = "firstcjy"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
'设置的参数据写入数据库tca_init表中
Dim mrc As ADODB.Recordset
Dim msgtxt As String
f_port = Combo1.Text
f_btl = Combo2.Text
f_bsq = "1"
If Option1.Value Then
f_bsq = "1"
Else
f_bsq = "0"
End If
sqltxt = "select * from tca_init"
msgtxt = ""
Set mrc = ExecuteSQL(sqltxt, msgtxt)
If mrc.RecordCount > 0 Then
'修改记录
mrc.MoveFirst
mrc.Fields("f_btl") = f_btl
mrc.Fields("f_port") = f_port
mrc.Fields("f_psq") = f_bsq
mrc.Update
mrc.Close
MsgBox "设置成功!", vbOKOnly
Else
'添加一条记录
mrc.AddNew
mrc.Fields("f_btl") = f_btl
mrc.Fields("f_port") = f_port
mrc.Fields("f_psq") = f_bsq
mrc.Update
mrc.Close
MsgBox "设置成功!", vbOKOnly
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim mrc As ADODB.Recordset
Dim sqltxt As String
Dim msgtxt As String
Combo1.AddItem "COM_0"
Combo1.AddItem "COM_1"
Combo1.AddItem "COM_2"
Combo1.AddItem "COM_3"
Combo1.ListIndex = 0
Combo2.AddItem "38400"
Combo2.AddItem "19200"
Combo2.AddItem "9600"
Combo2.AddItem "4800"
Combo2.AddItem "2400"
Combo2.ListIndex = 0
Option1.Value = True
Option2.Value = False
'从数据库中取参数,初始化界面
sqltxt = "select * from tca_init"
msgtxt = ""
Set mrc = ExecuteSQL(sqltxt, msgtxt)
If mrc.RecordCount > 0 Then
mrc.MoveFirst
f_port = mrc.Fields("f_port").Value
f_btl = mrc.Fields("f_btl").Value
f_psq = mrc.Fields("f_psq").Value
mrc.Close
If f_psq = "1" Then
Option1.Value = True
Option2.Value = False
Else
Option1.Value = False
Option2.Value = True
End If
If f_port = "COM_0" Then Combo1.ListIndex = 0
If f_port = "COM_1" Then Combo1.ListIndex = 1
If f_port = "COM_2" Then Combo1.ListIndex = 2
If f_port = "COM_3" Then Combo1.ListIndex = 3
If f_btl = "38400" Then Combo2.ListIndex = 0
If f_btl = "19200" Then Combo2.ListIndex = 1
If f_btl = "9600" Then Combo2.ListIndex = 2
If f_btl = "4800" Then Combo2.ListIndex = 3
If f_btl = "2400" Then Combo2.ListIndex = 4
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -