?? frv2.frm
字號:
Attribute VB_Exposed = False
Option Explicit
Dim PicB As Boolean
Const cmdNum As Byte = 3
Dim mWav(cmdNum + 1) As Boolean '按鈕數組有無鼠標移動到的標志
Dim cWav(cmdNum + 1) As Boolean '按鈕數組的按下狀態
Dim cmdToolTip(cmdNum) As New ToolTip '波形按鈕標簽
Dim PicMove As Boolean 'pic9 和pic8移動的標志
Private Sub Command1_Click()
Dim Step As Single
Dim OutV As Single
Dim flag As Boolean '判斷波形是否在工作
Dim i As Byte
Dim TemPath As String
Dim Response As Integer
If Command1.Caption = "工作" Then '開始工作,發送命令
For i = 1 To cmdNum - 1
flag = cWav(i) Or cWav(i + 1) Or flag
Next
If flag Then '有波形在輸出
Response = MsgBox("波形輸出正在工作,是否停止?", vbYesNo + vbQuestion + vbDefaultButton1)
If Response = vbNo Then '不停止波形
SSTab1.Tab = 1
Exit Sub '退出
Else '停止波形
cWav(CmdIndex) = False '參數重置,按鈕彈起
TemPath = "Pic\48WAV" & CmdIndex & ".ico"
Call Path(TemPath)
Timer2.Enabled = False
Timer2.Enabled = False 'timer2停止工作,波形動畫停止
Picture8(0).Visible = False '圖片框不可見
Picture8(1).Visible = False
Picture8(0).Left = 0 '初始化圖片框參數
Picture8(1).Left = -Picture8(1).Width
End If
End If
Command1.Caption = "暫停"
Call SendB(HScroll1.Value) '發送命令數據 防止誤碼多發送一次
Call SendB(HScroll1.Value) '發送命令數據
Step = 10 / 255
OutV = Step * HScroll1.Value - 5 + (HScroll2.Value - 100) * 0.01
SEG1.Value = Format$(OutV, "0.00")
Else
SEG1.Value = Format$(Null, "0.00") '停止工作
Command1.Caption = "工作"
Call SendB(&H80)
End If
End Sub
'Private Sub Command1_Click() '+ - 按鈕
'If SEG2.Value < 1 Then
' SEG2.Value = Format$(SEG2.Value + 0.01, "0.00")
' If SEG1.Value <> Format$(Null, "0.00") Then
' SEG1.Value = Format$(SEG1.Value + 0.01, "0.00")
' End If
'Else
' MsgBox "已經達到上限!"
'End If
'End Sub
'Private Sub Command2_Click()
'If SEG2.Value > -1 Then
' SEG2.Value = Format$(SEG2.Value - 0.01, "0.00")
' If SEG1.Value <> Format$(Null, "0.00") Then
' SEG1.Value = Format$(SEG1.Value - 0.01, "0.00")
' End If
'Else
' MsgBox "已經達到下限!"
'End If
'End Sub
Private Sub Command3_Click()
Unload Me
Form1.Show
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Command5_Click(Index As Integer)
Dim TemPath As String
Dim i As Byte
If Not cWav(Index) Then '該鍵之前未被按下,現在已按下
If Command1.Caption = "暫停" Then '若電壓輸出在工作
Dim Response As Integer
Response = MsgBox("電源輸出正在工作,是否停止?", vbYesNo + vbQuestion + vbDefaultButton1)
If Response = vbNo Then '按下“否”
SSTab1.Tab = 0 '跳轉的電壓輸出面板
Exit Sub
Else '按下"是",電源停止,波形工作:電壓輸出面板重置
Command1.Caption = "工作"
SEG1.Value = Format$(Null, "0.00") 'seg1不顯示
End If
End If
Command5(Index).Picture = Command5(Index).DownPicture
cmdToolTip(Index).ToolTipText = "工作"
CmdIndex = Index '模塊變量
Call SendW '發送指令產生波形
Timer2.Enabled = True 'timer2開始工作,波形動畫開始
For i = 1 To cmdNum
If i <> Index Then
If cWav(i) = True Then '若已經有其他按鈕按下則彈起
cWav(i) = False
TemPath = "Pic\48WAV" & i & ".ico"
Call Path(TemPath)
Command5(i).Picture = LoadPicture(FullPath)
cmdToolTip(i).ToolTipText = "停止"
End If
End If
Next
Else '該鍵已經按下-彈起
TemPath = "Pic\48WAV" & Index & ".ico"
Call Path(TemPath)
Command5(Index).Picture = LoadPicture(FullPath)
cmdToolTip(Index).ToolTipText = "停止"
Call SendB(&H80) '停止波形的產生
Timer2.Enabled = False 'timer2停止工作,波形動畫停止
Picture8(0).Visible = False '圖片框不可見
Picture8(1).Visible = False
Picture8(0).Left = 0 '初始化圖片框參數
Picture8(1).Left = -Picture8(1).Width
End If
cWav(Index) = Not cWav(Index) '狀態反置
End Sub
Private Sub Command5_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim i As Byte
Dim TemPath As String
If Not mWav(Index) Then '鼠標移動在上面載入藍色圖標
TemPath = "Pic\48bWAV" & Index & ".ico"
Call Path(TemPath)
Command5(Index).Picture = LoadPicture(FullPath)
mWav(Index) = True
End If
For i = 1 To cmdNum '其他按鈕若載入藍色圖標則重置
If i <> Index Then
If mWav(i) And (Not cWav(i)) Then
TemPath = "Pic\48WAV" & i & ".ico"
Call Path(TemPath)
Command5(i).Picture = LoadPicture(FullPath)
mWav(i) = False
End If
End If
Next
End Sub
Private Sub Command6_Click()
If SEG3.Value < 500 Then
SEG3.Value = Format$(SEG3.Value + 50, "000")
Dim i As Byte
Dim flag As Boolean
For i = 1 To cmdNum - 1
flag = cWav(i) Or cWav(i + 1) Or flag
Next
If flag Then ' 若波形工作 發送數據
Call SendW '發送波形頻率命令
End If
Else
MsgBox "已經達到上限!"
End If
End Sub
Private Sub Command7_Click()
If SEG3.Value > 50 Then
SEG3.Value = Format$(SEG3.Value - 50, "000")
Dim i As Byte
Dim flag As Boolean
For i = 1 To cmdNum - 1
flag = cWav(i) Or cWav(i + 1) Or flag
Next
If flag Then ' 若波形工作 發送數據
Call SendW '發送波形頻率命令
End If
Else
MsgBox "已經達到下限!"
End If
End Sub
Private Sub Form_Load()
'----------------Initialize Parameter-------------------------
With StatusBar1.Panels 'statusBar setting
.Item(1).Text = "打開串口:" & OpenPort
.Item(2).Text = "設置:" & PortSet
' .Item(3).Text = "接收數據:" & RecNum
.Item(5).Text = "Power By Sphinx 08"
End With
SEG1.Value = Format$(Null, "0.00") '設置SEG1的初始值
SEG2.Value = Format$(0, "0.00")
SEG3.Value = Format$(50, "000")
Dim i As Byte
For i = 1 To cmdNum
mWav(i) = False
cWav(i) = False
Next
With Line7 '設置分割線
.BorderColor = vbWhite
.BorderWidth = 3
.x1 = Line1.x1 + 22
.x2 = Line1.x2 + 22
.y1 = Line1.y1
.y2 = Line1.y2
End With
Line1.ZOrder 0
'---------------------------picbox---------------------------
Picture7.Width = Picture8(0).Width
Picture8(0).Left = 0
Picture8(0).Top = Picture8(1).Top
Picture8(1).Left = -Picture8(1).Width
Timer2.Enabled = False
'---------------------------ToolTip------------------------------
Set cmdToolTip(1).ParentControl = Command5(1)
cmdToolTip(1).ToolTipTitle = "鋸齒波"
cmdToolTip(1).ToolTipText = "停止"
cmdToolTip(1).Create
Set cmdToolTip(2).ParentControl = Command5(2)
cmdToolTip(2).ToolTipTitle = "矩形波"
cmdToolTip(2).ToolTipText = "停止"
cmdToolTip(2).Create
Set cmdToolTip(3).ParentControl = Command5(3)
cmdToolTip(3).ToolTipTitle = "三角波"
cmdToolTip(3).ToolTipText = "停止"
cmdToolTip(3).Create
End Sub
Private Sub Form_Unload(Cancel As Integer) '輸出電壓0
SendB (&H80)
SendB (&H80)
Unload Form1 '卸載主窗口
End Sub
Private Sub HScroll1_Change()
Dim Step As Single
Dim OutV As Single
If Command1.Caption = "暫停" Then '面板工作時才發送數據
Call SendB(HScroll1.Value)
Step = 10 / 255
OutV = Step * HScroll1.Value - 5 + (HScroll2.Value - 100) * 0.01
SEG1.Value = Format$(OutV, "0.00")
End If
End Sub
Private Sub HScroll2_Change()
SEG2.Value = Format$((HScroll2.Value - 100) * 0.01, "0.00")
If SEG1.Value <> Format$(Null, "0.00") Then
Dim Step As Single
Dim OutV As Single
Step = 10 / 255
OutV = Step * HScroll1.Value - 5 + (HScroll2.Value - 100) * 0.01
SEG1.Value = Format$(OutV, "0.00")
End If
End Sub
Private Sub SSTab1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim i As Byte
Dim TemPath As String
For i = 1 To cmdNum '若有按鈕載入藍色圖標則重置
If mWav(i) And (Not cWav(i)) Then
TemPath = "Pic/48WAV" & i & ".ico"
Call Path(TemPath)
Command5(i).Picture = LoadPicture(FullPath)
mWav(i) = False
End If
Next
End Sub
Private Sub Timer1_Timer()
If PicB Then
Call Path("Pic/48wr.ico")
Image1.Picture = LoadPicture(FullPath)
'Image1.Picture = LoadPicture(".\Pic\48vr.ico")
PicB = False
Else
Call Path("Pic/48wb.ico")
Image1.Picture = LoadPicture(FullPath)
'Image1.Picture = LoadPicture(".\Pic\48vb.ico")
PicB = True
End If
End Sub
Private Sub Timer2_Timer()
Static PreWav As Byte
Dim i As Byte
Dim TemPath As String
Timer2.Interval = 110 - SEG3.Value / 5 '移動速率
If PreWav <> CmdIndex Then '按鈕的改變則載入不同的圖片
PreWav = CmdIndex
TemPath = "Pic\MWAV" & CmdIndex & ".jpg"
Call Path(TemPath)
Picture8(0).Picture = LoadPicture(FullPath)
Picture8(1).Picture = LoadPicture(FullPath)
Else '按鈕不變載入的圖片不變
Picture8(0).Visible = True '圖片框可見
Picture8(1).Visible = True
For i = 0 To 1
If Picture8(i).Left >= Picture8(i).Width Then '當圖片的left到達容器的末端,圖片回到容器的左端
Picture8(i).Left = -Picture8(i).Width
End If
Picture8(i).Left = Picture8(i).Left + 90
Next
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -