⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 editoutf.frm

📁 AD9954源码
💻 FRM
📖 第 1 页 / 共 2 页
字号:
            txtTW(0).Text = Mid(TWBin, 25, 8)
        End If
        
        If Not (ActiveControl Is txtTW(1)) Then
            txtTW(1).Text = Mid(TWBin, 17, 8)
        End If
        
        If Not (ActiveControl Is txtTW(2)) Then
            txtTW(2).Text = Mid(TWBin, 9, 8)
        End If
        
        If Not (ActiveControl Is txtTW(3)) Then
            txtTW(3).Text = Mid(TWBin, 1, 8)
        End If
    Else
        'Output frequency textbox
        If Not (ActiveControl Is txtOutputFreqVal) Then
            'Ajust the maximum length of the textbox
            AdjustOFTboxLen value
            
            'Update this box because it is not currently active
            OutFreqval = DecTW2CarrierFreq(value)
            
            txtOutputFreqVal.Text = FormatOutFreq(OutFreqval)
        End If
        
        'Decimal value textbox
        If Not (ActiveControl Is txtTWDec) Then
            txtTWDec.Text = Format(value, "0000000000")
        End If
        
        'Hex textbox
        If Not (ActiveControl Is txtTWHex) Then
            'Update this box because it is not currently active
            txtTWHex.Text = cbaseHex(value, 8)
            txtTWHex.Refresh
        End If
        
        'Generate a binary string representing the tunning word
        TWBin = cbaseDec2Bin(value, TWBits)
        
        'Binary TextBoxes
        If Not (ActiveControl Is txtTW(0)) Then
            txtTW(0).Text = Mid(TWBin, 25, 8)
        End If
        
        If Not (ActiveControl Is txtTW(1)) Then
            txtTW(1).Text = Mid(TWBin, 17, 8)
        End If
        
        If Not (ActiveControl Is txtTW(2)) Then
            txtTW(2).Text = Mid(TWBin, 9, 8)
        End If
        
        If Not (ActiveControl Is txtTW(3)) Then
            txtTW(3).Text = Mid(TWBin, 1, 8)
        End If
    End If
End Sub

Public Sub ShowEditDialog(ByRef Tbox As TextBox, ByVal Title As String, ByVal SysClk As Variant, Optional SignedVals)
'    Dim OldOutputVal As String
'    Dim TWDecVal As Variant
    Dim OldLeft As Single
    Dim OldTop As Single
    
    Load frmEditOutFreq
    
    'Check to see if the user passed a "handle negative values" flag of true
    If IsMissing(SignedVals) Then
        NegValues = False
        txtTWDec.MaxLength = 10
    Else
        If SignedVals = True Then
            NegValues = True
            txtTWDec.MaxLength = 11
        Else
            NegValues = False
            txtTWDec.MaxLength = 10
        End If
    End If
    
    EditOutFreqSysClk = CDec(SysClk)
    
    'Set the title of the dialog
    frmEditOutFreq.Caption = Title
    
    'Store the value to be edited
    Set EditTbox = Tbox
    
    'Setup the textbox to the initial value
    txtOutputFreqVal.Text = Tbox.Text
    
    'Show the window off the screen so that it isn't seen yet
    Call SetWindowPos(Me.hWnd, HWND_NOTOPMOST, -500, -500, 0, 0, SWP_NOSIZE + SWP_SHOWWINDOW + SWP_NOACTIVATE)
    'Set the focus to the output text box
    txtOutputFreqVal.SetFocus
    Me.Visible = False
    
    'Calculate the decimal tuning word
    TWDecVal = Tbox.Tag
    
    'Update the other textboxes
    UpdateTW (TWDecVal)
    
    'Move the form back
    Me.Top = OldTop
    Me.Left = OldLeft
    
    'Show as modal
    Me.Show 1
    
    If OKHit = True Then
        'Ok was hit
        Tbox.Tag = txtTWDec.Text 'OutputFreqVal
        Tbox.Text = txtOutputFreqVal.Text
    End If
    
    'Unload the dialog
    Unload Me
End Sub

Private Sub txtOutputFreqVal_LostFocus()
'    Dim cncl As Boolean
'    txtOutputFreqVal_Validate (cncl)
'    If cncl Then
'        txtOutputFreqVal.SetFocus
'    End If
End Sub

Private Sub txtOutputFreqVal_Validate(Cancel As Boolean)
    Dim OutFreqval As Double
    Dim NegVal As Boolean
    Dim DecSepPos As Integer
    
    'If it is a null string then enter 0 as the default
    If txtOutputFreqVal.Text = "" Then
        txtOutputFreqVal.Text = Format(0, "0.000000000")
    End If
    
    'Format the string properly
    If IsNumeric(txtOutputFreqVal.Text) Then
        'Check to see if a negative number was entered
        If Left(txtOutputFreqVal.Text, 1) = sNegSign Then
            NegVal = True
        End If
        
        'Convert it to a double
        OutFreqval = Abs(CDbl(txtOutputFreqVal.Text))
        
        If OutFreqval >= CDbl(EditOutFreqSysClk) Then  ' CDbl(frmMain.txtExtClockFreq.Text)
            'MsgBox "The DDS output frequency should not exceed  the system clock.", vbApplicationModal + vbExclamation + vbOKOnly, "Output Frequency to High!!!"
            'OutFreqval = CDbl(EditOutFreqSysClk) * 0.4
            OutFreqval = DecTW2CarrierFreq((2 ^ 32) - 1, EditOutFreqSysClk)
            'Cancel = True
        End If
        
        'Calculate the decimal tuning word
        TWDecVal = CalculateDecTuningWord(OutFreqval)
        
        'Convert it to a double
        OutFreqval = CDbl(DecTW2CarrierFreq(TWDecVal))
        
        'Make the values negative
        If NegVal = True Then
            TWDecVal = -TWDecVal
            OutFreqval = -OutFreqval
        End If
                
        'Ajust the maximum length of the textbox
        AdjustOFTboxLen TWDecVal
        
        'Format and display the output frequency
        txtOutputFreqVal.Text = FormatOutFreq(OutFreqval)
                
        'Update the other textboxes
        UpdateTW (TWDecVal)
        
        '
        OKButton.SetFocus
    End If
    
End Sub

Private Sub txtTW_GotFocus(Index As Integer)
    'Select all of the text in the textbox
    SelectAllTxt txtTW(Index)
End Sub

Private Sub txtTW_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
            txtTW_Validate Index, cncl
    End Select
    

End Sub

Private Sub txtTW_Validate(Index As Integer, Cancel As Boolean)
    Dim TWBinVal As Variant
    Dim sTWBinVal As String
    
    'Fill any missing digits in with Zeros
    txtTW(Index).Text = String(8 - Len(txtTW(Index).Text), "0") & txtTW(Index).Text
        
        
    'If something non numeric is entered then zero the control
    If Not IsNumeric(txtTW(Index).Text) Then
        txtTW(Index).Text = Format(0, "0000000000")
    End If
    
    'If we need to handle negative values then use a different
    If NegValues Then
        TWBinVal = cbaseSignedBinS2Dec(txtTW(3).Text & txtTW(2).Text & txtTW(1).Text & txtTW(0).Text)
    Else
        'Get the value of the textbox
        TWBinVal = cbaseBinS2Dec(txtTW(3).Text & txtTW(2).Text & txtTW(1).Text & txtTW(0).Text)
    End If
    
'    If TWBinVal <= (2 ^ 32) - 1 Then
'        'Display the new value
'        txtTW(Index).Text = Format(TWBinVal, "0000000000")
'    Else
'        MsgBox "The decimal value of the Tunning Word should not exceed 4294967295"
'        TWBinVal = 0
'        txtTW(Index).Text = Format(TWBinVal, "0000000000")
'        Cancel = True
'    End If
'
    'Record the proper output frequency value
    'OutputFreqVal = DecTW2CarrierFreq(TWDecVal, TWBits, CLng(frmMain.txtIntClockFreq.Text))
    
    'Update the other textboxes
    UpdateTW (TWBinVal)
End Sub

Private Sub txtTWDec_GotFocus()
    'Select all of the text in the textbox
    SelectAllTxt txtTWDec
End Sub

Private Sub txtTWDec_KeyPress(KeyAscii As Integer)
    Dim cncl As Boolean
    'Filter out keys that arn't needed
    KeyAscii = iNumericKeysFilter(KeyAscii)
    If NegValues = False Then
        KeyAscii = PlusMinusKeysFilter(KeyAscii)
    End If
    
    Select Case KeyAscii
'        Case 46:
'            KeyAscii = 0
        Case 13:
            KeyAscii = 0
            txtTWDec_Validate cncl
    End Select
End Sub

Private Sub txtTWDec_Validate(Cancel As Boolean)
    Dim TWDecVal As Long
    Dim NegVal As Boolean
    
    'If something non numeric is entered then zero the control
    If Not IsNumeric(txtTWDec.Text) Then
        txtTWDec.Text = Format(0, "0000000000")
    End If
    
    'Check to see if the number is negative
'    If Left(txtTWDec.Text, 1) = sNegSign Then
'        NegVal = True
'    End If
    
    'Get the value of the textbox
    TWDecVal = CLng(txtTWDec.Text)
    
    If TWDecVal <= (2 ^ 32) - 1 Then
        'Display the new value
        txtTWDec.Text = Format(TWDecVal, "0000000000")
    Else
        'MsgBox "The decimal value of the Tunning Word should not exceed 4294967295"
        TWDecVal = 0
        txtTWDec.Text = Format(TWDecVal, "0000000000")
        Cancel = True
    End If
    
    'Record the proper output frequency value
    'OutputFreqVal = DecTW2CarrierFreq(TWDecVal, TWBits, CLng(frmMain.txtIntClockFreq.Text))
    
    'Update the other textboxes
    UpdateTW (TWDecVal)
End Sub

Private Sub txtTWHex_GotFocus()
    'Select all of the text in the textbox
    SelectAllTxt txtTWHex
End Sub

Private Sub txtTWHex_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
        
        '
        txtTWHex_Validate cncl
    End If
End Sub

Private Sub txtTWHex_Validate(Cancel As Boolean)
    Dim TWHexVal As Variant
        
    TWHexVal = 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
    
    If NegValues Then
        'Get the decimal value of the hex text box
        TWHexVal = cbaseSignedHex2Dec(txtTWHex.Text)
    Else
        'Get the decimal value of the hex text box
        TWHexVal = cbaseHexStr2Dec(txtTWHex.Text)
    End If
    
    If TWHexVal <= (2 ^ 32) - 1 Then
        If NegValues Then
            'Display the new value
            txtTWHex.Text = cbaseSignedDec2Hex(TWHexVal, 8)
        Else
            'Display the new value
            txtTWHex.Text = cbaseHex(TWHexVal, 8)
        End If
    Else
        MsgBox "The hex value of the Tunning Word should not exceed FFFFFFFF"
        TWHexVal = 0
        txtTWHex.Text = cbaseHex(TWHexVal, 8)
        Cancel = True
    End If
    
    'Update the other textboxes
    UpdateTW (TWHexVal)
End Sub

Private Sub vscDecTWVal_Change()
    Dim MinIncVal As Variant
    Dim NewVal As Double
    Dim MaxVal As Variant
    Dim MinVal As Variant
    
    'Setup the maximum and minimum values
    If NegValues Then
        MaxVal = CDec(2 ^ (TWBits - 1))
        MinVal = CDec(-MaxVal + 1)
    Else
        MaxVal = CDec(2 ^ TWBits)
        MinVal = CDec(0)
    End If
    
    If vscDecTWVal.value = -1 Then
        
        'Calulate the new value
        NewVal = CDec(txtTWDec.Text) - 1
        
        'If the new value is valid then update the other controls
        If NewVal >= MinVal Then
            UpdateTW NewVal
        End If
        
        vscDecTWVal.value = 0
    End If
    
    If vscDecTWVal.value = 1 Then
        
        'Calulate the new value
        NewVal = CDec(txtTWDec.Text) + 1
        
        'If the new value is valid then update the other controls
        If NewVal <= MaxVal Then
            UpdateTW NewVal
        End If
        
        vscDecTWVal.value = 0
    End If
End Sub

'Sets the length of the output frequency textbox
Private Sub AdjustOFTboxLen(ByVal TWDecVal As Variant)
    Dim DecSepPos As Integer
    Dim OutFreqval As Double
    
    'Calculate the output frequency value
    OutFreqval = CDbl(DecTW2CarrierFreq(TWDecVal))
    
    'Get the decimal position
    DecSepPos = InStr(1, FormatOutFreq(OutFreqval), sDecSep)
    If NegValues = False Then
        'Adjust the maximum length
        Select Case DecSepPos
            Case 2:
                txtOutputFreqVal.MaxLength = 12
            Case 3:
                txtOutputFreqVal.MaxLength = 13
            Case Else:
                txtOutputFreqVal.MaxLength = 14
        End Select
    Else
        'Adjust the maximum length
        Select Case DecSepPos
            Case 3:
                txtOutputFreqVal.MaxLength = 13
            Case 4:
                txtOutputFreqVal.MaxLength = 14
            Case Else:
                txtOutputFreqVal.MaxLength = 15
        End Select
    End If
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -