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

📄 editoutf.frm

📁 Some mathematical functions
💻 FRM
📖 第 1 页 / 共 2 页
字号:

End Sub

Private Sub UpdateTW(ByVal Value As Variant)
    Dim TWBin As String
    Dim OutFreqVal As Variant
        
    'Output frequency textbox
    If Not (ActiveControl Is txtOutputFreqVal) Then
        'Update this box because it is not currently active
        OutFreqVal = DecTW2CarrierFreq(Value, TWBits, CDbl(frmMain.txtIntClockFreq.Text))
        
        If OutFreqVal >= 100 Then
            txtOutputFreqVal.Text = Format(OutFreqVal, "000.000000000")
        ElseIf OutFreqVal >= 10 Then
            txtOutputFreqVal.Text = Format(OutFreqVal, "00.000000000")
        Else
            txtOutputFreqVal.Text = Format(OutFreqVal, "0.000000000")
        End If
        
    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 Sub

Public Sub ShowEditDialog(ByRef Tbox As TextBox, ByVal Title As String)
'    Dim OldOutputVal As String
'    Dim TWDecVal As Variant
    Dim OldLeft As Single
    Dim OldTop As Single
    
'    MaxVal = MaxValue
'    MinVal = MinValue
    
    '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 'DecFix(CalculateDecTuningWord(CDbl(Tbox.Tag), CDbl(frmMain.txtExtClockFreq), TWBits))
    'OutputFreqVal =
    
'    TWDecVal = TWVal
    'Update the other textboxes
    UpdateTW (TWDecVal)
    
    'Show the dialog
'    Me.Visible = True
    
    'Set the focus to the OutputVal textbox
'    txtOutputFreqVal.SetFocus
    
'    Me.Visible = False
    
    'Move the form back
    Me.Top = OldTop
    Me.Left = OldLeft
    
    'Show as modal
    Me.Show 1
    
    If OKHit = True Then
        'Ok was hit
        Tbox.Text = txtOutputFreqVal.Text
        Tbox.Tag = txtTWDec.Text 'OutputFreqVal
        'Record the new TunningWord value
        'TunningWord = TWDecVal
        'TWVal = CDec(txtTWDec.Text)
    End If
    
    'Unload the dialog
    Unload Me

      'Set the text of the box to the new value
'    txtOutputFreqVal.Text = Tbox
 
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
    
    '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
        'Convert it to a double
        OutFreqVal = CDbl(txtOutputFreqVal.Text)
        
        If OutFreqVal >= CDbl(frmMain.txtIntClockFreq.Text) 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(frmMain.txtIntClockFreq.Text) * 0.4
            Cancel = True
        End If
'        If OutFreqVal > (0.4 * CDbl(frmMain.txtExtClockFreq.Text)) Then
'            MsgBox "It is recomened that the output frequency not exceed" & vbCrLf & "40% of the system clock.", vbApplicationModal + vbExclamation + vbOKOnly, "Output Frequency Exceeding Nyquist"
'        End If
        
        'Get the closest actual output value that the part can do
        OutFreqVal = CDbl(GetClosestOutFreq(CStr(OutFreqVal)))
        
        'Store the text before it is formated
        'OutFreqVal = CDbl(OutputFreqVal)
        
        If OutFreqVal >= 100 Then
            txtOutputFreqVal.Text = Format(OutFreqVal, "000.000000000")
        ElseIf OutFreqVal >= 10 Then
            txtOutputFreqVal.Text = Format(OutFreqVal, "00.000000000")
        Else
            txtOutputFreqVal.Text = Format(OutFreqVal, "0.000000000")
        End If
        
        'Calculate the decimal tuning word
        TWDecVal = DecFix(CalculateDecTuningWord(OutFreqVal, CDbl(frmMain.txtIntClockFreq), TWBits))
                
        '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
    
    'Get the value of the textbox
    TWBinVal = cbaseBinS2Dec(txtTW(3).Text & txtTW(2).Text & txtTW(1).Text & txtTW(0).Text)
    
'    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)
    
    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
    
    'If something non numeric is entered then zero the control
    If Not IsNumeric(txtTWDec.Text) Then
        txtTWDec.Text = Format(0, "0000000000")
    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
    
    'Get the decimal value of the hex text box
    TWHexVal = cbaseHexStr2Dec(txtTWHex.Text)
    
    If TWHexVal <= (2 ^ 32) - 1 Then
        'Display the new value
        txtTWHex.Text = cbaseHex(TWHexVal, 8)
    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
    
    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 >= 0 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 <= 4294967295# Then
            UpdateTW NewVal
        End If
        
        vscDecTWVal.Value = 0
    End If
End Sub

Private Sub vscOutputFreq_Change()
'    Dim MinIncVal As Variant
'    Dim NewVal As Double
'
'    If vscOutputFreq.Value = -1 Then
'        'Calculate the minimum output freq at the current clock
'        MinIncVal = DecTW2CarrierFreq(1, TWBits, CDbl(frmMain.txtIntClockFreq.Text))
'
'        NewVal = CDbl(OutputFreqVal) - MinIncVal
'        If NewVal >= 0 Then
'            'Store the full string value
'            OutputFreqVal = NewVal
'            'Calculate the new tunning word value
'            NewVal = DecFix(CalculateDecTuningWord(NewVal, CDbl(frmMain.txtIntClockFreq.Text), TWBits))
'            UpdateTW NewVal
'        End If
'
'        vscOutputFreq.Value = 0
'    End If
'
'    If vscOutputFreq.Value = 1 Then
'        'Calculate the minimum output freq at the current clock
'        MinIncVal = DecTW2CarrierFreq(1, TWBits, CDbl(frmMain.txtIntClockFreq.Text))
'
'        NewVal = CDbl(OutputFreqVal) + MinIncVal
'        If NewVal < CDbl(frmMain.txtIntClockFreq.Text) Then
'            'Store the full string value
'            OutputFreqVal = NewVal
''            txtOutputFreqVal.Text = NewVal
'            NewVal = DecFix(CalculateDecTuningWord(NewVal, CDbl(frmMain.txtIntClockFreq.Text), TWBits))
'            UpdateTW NewVal
'        End If
'
'        vscOutputFreq.Value = 0
'    End If
End Sub

⌨️ 快捷键说明

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