📄 frmeditramphaseoffset.frm
字号:
'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, Optional NegVals)
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)
KeyAscii = PlusMinusKeysFilter(KeyAscii)
' If NegValues = True Then
' If InStr(1, txtDecVal.Text, "-") Then
' 'If a negative sign has been added then make the max length 6
' txtDecVal.MaxLength = 6
' If KeyAscii = Asc("-") Then
' KeyAscii = 0
' End If
' Else
' txtDecVal.MaxLength = 5
' End If
' End If
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
MsgBox "The hex value of the Phase Offset should not exceed " & cbaseHex(NumPhaseVals - 1, 2)
POHexVal = 0
txtHexVal.Text = cbaseDec2Hex(POHexVal, 4)
Cancel = True
End If
' If NegValues Then
' If POHexVal > (NumPhaseVals - 1) Then
' MsgBox "The hex value of the Phase Offset should not be less than C001 Hex"
' POHexVal = 0
' txtHexVal.Text = cbaseSignedDec2Hex(POHexVal, 4)
' Cancel = True
' End If
' End If
'Display the new value
txtHexVal.Text = cbaseDec2Hex(POHexVal, 4)
'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)
MinVal = CalcPO(0)
'Make sure that the value entered is numeric
If Not IsNumeric(txtSearchPhaseOff.Text) Then
txtSearchPhaseOff.Text = Format("0.000", 0)
End If
' If NegValues Then
'
' MinVal = CalcPO(-16383)
'
' '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
' 'Make sure that the value typed isn't les than the minimum value
' If CDbl(txtSearchPhaseOff.Text) < MinVal Then
' 'Set it to the max
' txtSearchPhaseOff.Text = Format("0.000", CalcPO(0))
' 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
' Else
'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
' End If
'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 NegValues Then
' txtDecVal.MaxLength = 6
' End If
If NewVal >= -16383 And NewVal <= 16383 Then
'Update the new values
UpdatePO NewVal
End If
vscPhaseOffset.value = 0
End Sub
Private Sub AdjustPOTboxLen()
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -