📄 form1.frm
字号:
Height = 255
Left = 3960
TabIndex = 12
Top = 1200
Width = 675
End
Begin VB.Label Label5
Caption = "校验"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 3120
TabIndex = 11
Top = 1200
Width = 555
End
Begin VB.Label Label4
Caption = "数据位"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 2160
TabIndex = 10
Top = 1200
Width = 735
End
Begin VB.Label Label3
Caption = "波特率"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 1080
TabIndex = 9
Top = 1200
Width = 855
End
Begin VB.Label Label2
Caption = "串口"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 240
TabIndex = 8
Top = 1200
Width = 435
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim C1flag As Boolean '鼠标是否在按钮上的标志。False为在按钮上
Dim C2flag As Boolean
Dim F1flag As Boolean '鼠标是否在窗体上的标志
Dim ProValue As Byte '进度条的值
Dim ToolTip1 As New ToolTip
Dim ToolTip2 As New ToolTip
Private Sub Command1_Click() '按键按下时Timer开始计时ProgressBar工作
On Error GoTo PortErr1 '出错
Call MSCommset
Timer1.Enabled = True
ProgressBar1.Visible = True
Form1.Enabled = False '窗体不可操作,防止再按下其他按钮
Exit Sub
PortErr1: '串口设置出错
MsgBox "Port Setting Error!!"
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If C1flag = True Then '鼠标第一次移到按钮上
Call Path("Pic\64vb.ico")
Command1.Picture = LoadPicture(FullPath)
'Command1.Picture = LoadPicture(".\Pic\64vb.ico")
C1flag = 0
F1flag = 1
End If
End Sub
Private Sub Command2_Click()
On Error GoTo PortErr2 '出错
Call MSCommset
Timer1.Enabled = True
ProgressBar1.Visible = True
Form1.Enabled = False '窗体不可操作,防止再按下其他按钮
Exit Sub
PortErr2: '串口设置出错
MsgBox "Port Setting Error!!"
End Sub
Private Sub Command2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If C2flag = True Then
Call Path("Pic/64wb.ico")
Command2.Picture = LoadPicture(FullPath)
'Command2.Picture = LoadPicture(".\Pic\64wb.ico")
C2flag = 0
F1flag = 1
End If
End Sub
Private Sub Form_Load()
'----------------------装载进入托盘-----------------------
' nfIconData.hWnd = Me.hWnd
' nfIconData.uID = Picture2.Picture
' nfIconData.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
' nfIconData.uCallbackMessage = WM_MOUSEMOVE
' nfIconData.hIcon = Me.Icon.Handle
' nfIconData.szTip = "基于PC与单片机的数字电压表和电压源" & vbNullChar
' nfIconData.cbSize = Len(nfIconData)
' Call Shell_NotifyIcon(NIM_ADD, nfIconData)
' ShowWindow Me.hWnd, SW_HIDE
'---------------------------------------------------------
'Call FrmDisCtr(Form1)
C1flag = True
C2flag = True
F1flag = True
Combo1.Text = Combo1.List(0)
Combo2.Text = Combo2.List(3)
Combo3.Text = Combo3.List(2)
Combo4.Text = Combo4.List(0)
Combo5.Text = Combo5.List(0)
ProgressBar1.Visible = False
ProValue = 0
ProgressBar1.Value = ProValue
Timer1.Enabled = False
'--------------------------ToolTip----------------------------
Set ToolTip1.ParentControl = Command1
ToolTip1.ToolTipTitle = ""
ToolTip1.ToolTipText = "数字电压表"
ToolTip1.Create
Set ToolTip2.ParentControl = Command2
ToolTip2.ToolTipTitle = ""
ToolTip2.ToolTipText = "数字电压源"
ToolTip2.Create
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If F1flag = True Then '鼠标第一次移上窗体
Call Path("Pic\64v.ico")
Command1.Picture = LoadPicture(FullPath)
Call Path("Pic\64w.ico")
Command2.Picture = LoadPicture(FullPath)
'Command1.Picture = LoadPicture(".\Pic\64v.ico")
'Command2.Picture = LoadPicture(".\Pic\64w.ico")
C1flag = 1
C2flag = 1
F1flag = 0
Label7.Caption = ""
End If
End Sub
Private Sub Picture3_Click()
PortSet = Form1.Combo2.Text & "," & Form1.Combo3.Text & "," & _
Form1.Combo4.Text & "," & Form1.Combo5.Text
End Sub
Private Sub Label8_Click()
ShellExecute hwnd, "OPEN", ".\help\help.chm", "", "", 1 '打开CHM文件
End Sub
Private Sub Label9_Click()
About.Show
End Sub
Private Sub MSComm1_OnComm()
If ProgressBar1.Value = 100 Then '当进度条滚满才开始接受
Select Case MSComm1.CommEvent
Case comEvReceive '接受ADC的转换数值
Dim Volt As Single
Dim Step As Single
ReDim Sbyte(0)
Sbyte = MSComm1.Input
Step = 5 / 255
Volt = Step * Sbyte(0) + FrV.SEG2.Value
If FrV.Command8.Caption = "暂停" Then
FrV.SEG1.Value = Format(Volt, "0.00") '传递给SEG
End If
' RecNum = RecNum + 1 '接收记录加1
' FrV.StatusBar1.Panels.Item(3).Text = "接收数据:" & RecNum '显示
End Select
End If
End Sub
Private Sub Timer1_Timer()
ProgressBar1.Value = ProValue
If ProValue < 50 Then
Timer1.Interval = 2 'ProgressBar.Value=0~50的速度
ProValue = ProValue + 1
If ProValue < 15 Then
Label7.Caption = "正在初始化串口.."
ElseIf ProValue < 30 Then
Label7.Caption = "正在初始化串口...."
Else
Label7.Caption = "正在初始化串口......"
End If
ElseIf ProValue < 100 Then
Timer1.Interval = 1 'ProgressBar.Value=50~100的速度
ProValue = ProValue + 2
If Not C1flag = True Then '按钮1按下
If ProValue < 65 Then
Label7.Caption = "正在打开数字电压表面板.."
ElseIf ProValue < 80 Then
Label7.Caption = "正在打开数字电压表面板...."
Else
Label7.Caption = "正在打开数字电压表面板......"
End If
Else '按钮2按下
If ProValue < 65 Then
Label7.Caption = "正在打开数字电压源面板.."
ElseIf ProValue < 80 Then
Label7.Caption = "正在打开数字电压源面板...."
Else
Label7.Caption = "正在打开数字电压源面板......"
End If
End If
Else '进度条满
Timer1.Enabled = False
ProgressBar1.Visible = False
Form1.Enabled = True
Label7.Caption = ""
Me.Hide '主窗口隐藏
If Not C1flag Then
FrV.Show '装载电压表控制窗口
Else
FrV2.Show '装载电压源控制窗口
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -