📄 frmeditphaseoffset1.frm
字号:
Private Sub cmdCancel_Click()
'Release the pointer to the edit box
Set EditBox = Nothing
'Unload the form
Unload Me
End Sub
Private Sub cmdOK_Click()
'Return the value to the textbox
EditBox.Tag = txtDecVal.Text
EditBox.Text = txtSearchPhaseOff.Text
'Release the pointer to the edit box
Set EditBox = Nothing
'Unload the form
Unload Me
End Sub
Private Sub Form_Activate()
'Copy the text box value to the search box
txtSearchPhaseOff.Text = Format(CalcPO(EditBox.Tag), "0.000")
'Set the decimal value
txtDecVal.Text = EditBox.Tag
txtSearchPhaseOff.SetFocus
'Update all other displays
UpdatePO txtDecVal.Text
End Sub
Private Sub Form_Load()
' fraDDL.Move (txtSearchPhaseOff.Left + 120), (txtSearchPhaseOff.Top + txtSearchPhaseOff.Height + 30)
End Sub
'Function that edits the dialog box
Public Sub ShowEditDialog(Tbox As TextBox, ByVal SysClk As Variant)
Dim cntr As Integer
Dim lsb As Double
'Calculate the number of phase values
NumPhaseVals = 2 ^ NumPhaseBits
'Dim the array for the number of phase values
'ReDim PhaseOffArray(0 To NumPhaseVals - 1)
'Calculate the phase values
lsb = 360 / NumPhaseVals
'Clear the list box
'lstPhaseOffBox.Clear
'Build the phase value array and list for the list box
' For cntr = 0 To NumPhaseVals - 1
'PhaseOffArray(cntr) = cntr * lsb
'lstPhaseOffBox.AddItem Format(PhaseOffArray(cntr), "0.000")
'lstPhaseOffBox.ItemData(cntr) = cntr
' Next cntr
'Set the sysclk to so all functions will work.
EditDialogSysClk9859 = CDec(SysClk)
Set EditBox = Tbox
Me.Show 1
End Sub
Private Sub txtBinVal_GotFocus(Index As Integer)
'Select all of the text in the textbox
SelectAllTxt txtBinVal(Index)
End Sub
Private Sub txtBinVal_KeyPress(Index As Integer, KeyAscii As Integer)
Dim cncl As Boolean
'Filter out all keys but for the 0 and 1 keys
KeyAscii = BinKeysFilter(KeyAscii)
Select Case KeyAscii
Case 13:
KeyAscii = 0
txtBinVal_Validate Index, cncl
End Select
End Sub
Private Sub txtBinVal_Validate(Index As Integer, Cancel As Boolean)
Dim POBinVal As Variant
Dim sTWBinVal As String
'Fill any missing digits in with Zeros
If Index = 0 Then
txtBinVal(Index).Text = String(8 - Len(txtBinVal(Index).Text), "0") & txtBinVal(Index).Text
ElseIf Index = 1 Then
txtBinVal(Index).Text = String(6 - Len(txtBinVal(Index).Text), "0") & txtBinVal(Index).Text
End If
'If something non numeric is entered then zero the control
If Not IsNumeric(txtBinVal(Index).Text) Then
If Index = 0 Then
txtBinVal(Index).Text = String(8, "0")
ElseIf Index = 1 Then
txtBinVal(Index).Text = String(6, "0")
End If
End If
'Get the value of the textbox
POBinVal = cbaseBinS2Dec(txtBinVal(1).Text & txtBinVal(0).Text)
'Update the other textboxes
UpdatePO (POBinVal)
'Set the focus back to the ok button
cmdOK.SetFocus
End Sub
Private Sub txtDecVal_GotFocus()
'Select all of the text in the textbox
SelectAllTxt txtDecVal
End Sub
Private Sub txtDecVal_KeyPress(KeyAscii As Integer)
Dim cncl As Boolean
'Filter out keys that arn't needed
KeyAscii = iNumericKeysFilter(KeyAscii)
Select Case KeyAscii
Case 13:
KeyAscii = 0
txtDecVal_Validate cncl
End Select
End Sub
Private Sub txtDecVal_Validate(Cancel As Boolean)
Dim PODecVal As Long
'If something non numeric is entered then zero the control
If Not IsNumeric(txtDecVal.Text) Then
txtDecVal.Text = Format(0, "00000")
End If
'Get the value of the textbox
PODecVal = CInt(txtDecVal.Text)
If PODecVal <= (NumPhaseVals - 1) Then
'Display the new value
txtDecVal.Text = Format(PODecVal, "00000")
Else
MsgBox "The decimal value of the Phase Offset should not exceed " & (NumPhaseVals - 1)
PODecVal = 0
txtDecVal.Text = Format(PODecVal, "00000")
Cancel = True
End If
'Record the proper output frequency value
'OutputFreqVal = DecTW2CarrierFreq(TWDecVal, TWBits, CLng(frmMain.txtIntClockFreq.Text))
'Update the other textboxes
UpdatePO txtDecVal.Text
'Set the focus back to the ok button
cmdOK.SetFocus
End Sub
Private Sub txtHexVal_GotFocus()
'Select all of the text in the textbox
SelectAllTxt txtHexVal
End Sub
Private Sub txtHexVal_KeyPress(KeyAscii As Integer)
Dim cncl As Boolean
'Filter out all unwanted keys
KeyAscii = HexKeysFilter(KeyAscii)
If KeyAscii = 13 Then
'Throw the key away
KeyAscii = 0
'Validate the textbox
txtHexVal_Validate cncl
End If
End Sub
Private Sub txtHexVal_Validate(Cancel As Boolean)
Dim POHexVal As Variant
POHexVal = CDec(0)
'If something non numeric is entered then zero the control
' If Not IsNumeric(txtTWHex.Text) Then
' txtTWHex.Text = cbaseHex(0, 8)
' End If
'Get the decimal value of the hex text box
POHexVal = cbaseHexStr2Dec(txtHexVal.Text)
If POHexVal <= (NumPhaseVals - 1) Then
'Display the new value
txtHexVal.Text = cbaseHex(POHexVal, 4)
Else
MsgBox "The hex value of the Phase Offset should not exceed " & cbaseHex(NumPhaseVals - 1, 2)
POHexVal = 0
txtHexVal.Text = cbaseHex(POHexVal, 4)
Cancel = True
End If
'Update the other textboxes
UpdatePO (POHexVal)
'Set the focus back to the ok button
cmdOK.SetFocus
End Sub
Private Sub txtSearchPhaseOff_GotFocus()
'Select all of the text in the textbox
SelectAllTxt txtSearchPhaseOff
End Sub
Private Sub txtSearchPhaseOff_KeyPress(KeyAscii As Integer)
Dim cncl As Boolean
'Trash all unwanted keys
KeyAscii = NumericKeysFilter(KeyAscii)
KeyAscii = PlusMinusKeysFilter(KeyAscii)
If KeyAscii = GetDecSeparator(True) Then
If InStr(1, txtSearchPhaseOff.Text, sDecSep) And InStr(1, txtSearchPhaseOff.SelText, sDecSep) = 0 Then
KeyAscii = 0
End If
End If
If KeyAscii = 13 Then
KeyAscii = 0
txtSearchPhaseOff_Validate cncl
End If
End Sub
Private Sub txtSearchPhaseOff_Validate(Cancel As Boolean)
Dim dblval As Double
Dim DecVal As Long
Dim MaxVal As Double
MaxVal = CalcPO(16383)
'Make sure that the value entered is numeric
If Not IsNumeric(txtSearchPhaseOff.Text) Then
txtSearchPhaseOff.Text = Format("0.000", 0)
End If
'Make sure that the value typed isn't greater than the maximum value
If CDbl(txtSearchPhaseOff.Text) > MaxVal Then
'Set it to the max
txtSearchPhaseOff.Text = Format("0.000", CalcPO(16383))
End If
'Calculate the decimal value of the phase offset
DecVal = CalcPODecVal(txtSearchPhaseOff.Text)
'Calculate the actual phase offset that the part can do and display it.
txtSearchPhaseOff.Text = CalcPO(DecVal)
'Format the text
txtSearchPhaseOff.Text = Format(txtSearchPhaseOff.Text, "0.000")
'Update other controls
UpdatePO DecVal
'Set the focus back to the ok button
cmdOK.SetFocus
End Sub
Public Function CalcPODecVal(ByVal PO As Double) As Long
CalcPODecVal = CLng((PO * 2 ^ NumPhaseBits) / 360)
End Function
Private Sub vscPhaseOffset_Change()
Dim NewVal As Double
'
NewVal = txtDecVal.Text + vscPhaseOffset.value
If NewVal >= 0 And NewVal <= 16383 Then
'Update the new values
UpdatePO NewVal
End If
vscPhaseOffset.value = 0
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -