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

📄 frmeditramaddrrr.frm

📁 AD9954源码
💻 FRM
📖 第 1 页 / 共 2 页
字号:
    OKHit = False
    'Release the pointer to the textbox being edited
    Set EditTbox = Nothing
End Sub

Private Sub OKButton_Click()
    'Ok button hit
    OKHit = True
    
    'Hide the form
    Me.Hide
End Sub


Private Sub OKButton_GotFocus()
    shpOKHilight.Visible = False
End Sub

Private Sub OKButton_LostFocus()
    shpOKHilight.Visible = True
End Sub

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

Private Sub txtBin_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
            txtBin_Validate Index, cncl
    End Select
End Sub

Private Sub txtBin_Validate(Index As Integer, Cancel As Boolean)
    Dim BinVal As Variant
    Dim sBinVal As String
    
    'Fill any missing digits in with Zeros
    txtBin(Index).Text = String(8 - Len(txtBin(Index).Text), "0") & txtBin(Index).Text
        
        
    'If something non numeric is entered then zero the control
    If Not IsNumeric(txtBin(Index).Text) Then
        txtBin(Index).Text = Format(0, "00000000")
    End If
    
    'Get the value of the textbox
    BinVal = cbaseBinS2Dec(txtBin(1).Text & txtBin(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
    UpdateVals (BinVal)
        
    'Set the focus to the ok button
    OKButton.SetFocus
End Sub

Private Sub txtDec_GotFocus()
    'Select all of the text in the textbox
    SelectAllTxt txtDec
End Sub

Private Sub txtDec_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
            txtDec_Validate cncl
    End Select
End Sub

Private Sub txtDec_Validate(Cancel As Boolean)
    Dim DecVal As Long
    
    'If something non numeric is entered then zero the control
    If Not IsNumeric(txtDec.Text) Then
        txtDec.Text = Format(0, "00000")
    End If
    
    'Get the value of the textbox
    DecVal = CLng(txtDec.Text)
    
    If DecVal <= 65535 Then
        'Display the new value
        txtDec.Text = Format(DecVal, "00000")
    Else
        MsgBox "The decimal value of the Delta Frequency Ramp Rate Word should not exceed 65535"
        DecVal = 0
        txtDec.Text = Format(DecVal, "00000")
        Cancel = True
    End If
    
    'Record the proper output frequency value
    'OutputFreqVal = DecTW2CarrierFreq(TWDecVal, TWBits, CLng(frmMain.txtIntClockFreq.Text))
    
    'Update the other textboxes
    UpdateVals (DecVal)
        
    'Set the focus to the ok button
    OKButton.SetFocus
End Sub

Private Sub txtHex_GotFocus()
    'Select all of the text in the textbox
    SelectAllTxt txtHex
End Sub

Private Sub txtHex_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
        
        '
        txtHex_Validate cncl
    End If
End Sub

Private Sub txtHex_Validate(Cancel As Boolean)
    Dim HexVal As Variant
        
    HexVal = 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
    HexVal = cbaseHexStr2Dec(txtHex.Text)
    
    If HexVal <= 65535 Then
        'Display the new value
        txtHex.Text = cbaseHex(HexVal, 4)
    Else
        MsgBox "The hex value of the RAM Address Ramp Rate Word should not exceed FFFFh"
        HexVal = 0
        txtHex.Text = cbaseHex(HexVal, 4)
        Cancel = True
    End If
    
    'Update the other textboxes
    UpdateVals (HexVal)
        
    'Set the focus to the ok button
    OKButton.SetFocus
End Sub

Private Sub txtRampRateTime_GotFocus()
    'Select all of the text in the textbox
    SelectAllTxt txtRampRateTime
End Sub

Private Sub txtRampRateTime_KeyPress(KeyAscii As Integer)
    Dim cncl As Boolean
    Dim DecSepPos As Integer

    'Filter out all keys but the ones that are needed
    KeyAscii = NumericKeysFilter(KeyAscii)
    KeyAscii = PlusMinusKeysFilter(KeyAscii)
    Select Case KeyAscii
        Case 69, 101: 'Alpha key
            KeyAscii = 0
        Case iDecSep 'Decimal Seperator
            If InStr(1, txtRampRateTime.Text, sDecSep) And InStr(1, txtRampRateTime.SelText, sDecSep) = 0 Then
                KeyAscii = 0
            End If
        Case 13: 'Enter key hit
            KeyAscii = 0
            'Validate the text box
'            txtOutpuFreqVal_Validate Cncl
            txtRampRateTime_Validate cncl
        Case Else 'Only a passable key was pressed
            'Get the position of the decimal seperator
            DecSepPos = InStr(1, txtRampRateTime.Text, sDecSep)
            
            If txtRampRateTime.SelStart < DecSepPos And DecSepPos < 4 Then
                If IsPrintable(KeyAscii) Then
                    'Adjust the maximum length
                    Select Case DecSepPos
                        Case 2:
                            txtRampRateTime.MaxLength = 6
                        Case 3:
                            txtRampRateTime.MaxLength = 5
                        Case Else:
                            txtRampRateTime.MaxLength = 4
                    End Select
                Else
                    Select Case DecSepPos
                        Case 2:
                            txtRampRateTime.MaxLength = 6
                        Case 3:
                            txtRampRateTime.MaxLength = 5
                        Case Else
                            txtRampRateTime.MaxLength = 4
                    End Select
                End If
            End If

    End Select
End Sub

Private Sub UpdateVals(ByVal value As Variant)
    Dim BinVal As String
    Dim RampRateTime As Variant
        
    'Output frequency textbox
    If Not (ActiveControl Is txtRampRateTime) Then
        'Update this box because it is not currently active
        RampRateTime = CalculateRAMRRTime(value)
        txtRampRateTime.Text = FormatRAMRRT(CDbl(RampRateTime))
    End If
    
    'Decimal value textbox
    If Not (ActiveControl Is txtDec) Then
        txtDec.Text = Format(value, "00000")
    End If
    
    'Hex textbox
    If Not (ActiveControl Is txtHex) Then
        'Update this box because it is not currently active
        txtHex.Text = cbaseHex(value, 4)
        txtHex.Refresh
    End If
    
    'Generate a binary string representing the tunning word
    BinVal = cbaseDec2Bin(value, 16)
    
    'Binary TextBoxes
    If Not (ActiveControl Is txtBin(0)) Then
        txtBin(0).Text = Right(BinVal, 8)
    End If
    
    If Not (ActiveControl Is txtBin(1)) Then
        txtBin(1).Text = Left(BinVal, 8)
    End If
    
End Sub
Public Function GetClosestRRTime(ByVal RRstr As String) As String
    Dim LowVal As String
    Dim HiVal As String
    Dim dummy As Long
    Dim HiDiff As Double
    Dim LowDiff As Double
    Dim RetDecVal As Long
    
    'Calculate the tunning word value for the input string
    dummy = CalculateRAMRRWord(RRstr)
    
    'If they have entered a time larger than the maximum then clip the value
    If dummy > 65535 Then
        dummy = 65535
    End If
'
'    'Calculate the next availiable output frequency
    GetClosestRRTime = CalculateRAMRRTime(dummy)
    
'    If IsRRTimeValid(RRstr, cDecVal) Then
'        GetClosestRRTime = RRstr
'    Else
'        GetClosestRRTime = RRstr
'    End If
    
End Function

Private Sub txtRampRateTime_Validate(Cancel As Boolean)
    Dim RampRateTime As Double
    Dim sRampRateTime As String
    Dim DecVal As Long
    
    'If it is a null string then enter 0 as the default
    If txtRampRateTime.Text = "" Then
        txtRampRateTime.Text = Format(0, "0.00")
    End If
    
    'Format the string properly
    If IsNumeric(txtRampRateTime.Text) Then
        If txtRampRateTime.Text > MaxRAMRRT Then
            MsgBox "The vaid range for the Delta Frequency Ramp Rate Time is " & FormatRAMRRT(CDbl(MaxRAMRRT)) & "uS to " & MinRAMRRT & "uS ." & vbCrLf & "The value entered will be clipped!", vbApplicationModal + vbExclamation + vbOKOnly, "Maximum Ramp Rate Time Exceeded!!!"
            txtRampRateTime.Text = MaxRAMRRT
        End If
                
        'Get the matching RRW value
        'DecVal = GetMatchingRRW(txtRampRateTime.Text)
        DecVal = CalculateRAMRRWord(txtRampRateTime.Text)
        
        'Get the closest actual output value that the part can do
        txtRampRateTime.Text = CalculateRAMRRTime(DecVal)
        
        'Format the text for display
        txtRampRateTime.Text = FormatRAMRRT(CDbl(txtRampRateTime.Text))
        
        'Update the other textboxes
        UpdateVals (DecVal)
        
        'Set the focus to the ok button
        OKButton.SetFocus
    End If
End Sub

Private Sub vscRampRateTime_Change()
    Dim MinIncVal As Variant
    Dim NewVal As Double
    
    'Adjust the value and refresh all controls
    NewVal = txtDec.Text + vscRampRateTime.value
    If NewVal >= 0 And NewVal <= 65535 Then
        'Update the new values
        UpdateVals NewVal
    End If
    vscRampRateTime.value = 0
End Sub
''Checks to see if the Ramp Rate Time passed is a valid time
'Public Function GetMatchingRRW(ByVal RRT As String) As Long
'    Dim cntr As Long
'    Dim RRW As Long
'    Dim StartWord As Long
'    Dim sRRT As String
'    'Calculate the Ramp Rate word that goes with the Ramp Rate Time
'    RRW = CalculateRRWord(RRT)
'    StartWord = RRW - 4
'
'    'Loop through a few Ramp Rate words
'    For cntr = StartWord To RRW + 8
'        'Calcuate the RampRateTime
'        sRRT = FormatRAMRRT(CalculateRAMRRTime(cntr))
'        'If the passed time and the calculated time equal then the time is valid
'        If sRRT = FormatRAMRRT(RRT) Then
'            'Return the Decimal Value that goes with the time value
'            GetMatchingRRW = cntr
'            Exit For
'        Else
'            'Return the Decimal Value that goes with the time value
'            GetMatchingRRW = RRW
'        End If
'    Next cntr
'End Function
''Formats the Ramp Rate Time for display in a textbox
'Public Function FormatRAMRRT(ByVal RampRateTime As Double) As String
'    If RampRateTime >= 100 Then
'        FormatRAMRRT = Format(RampRateTime, "000.0000")
'    ElseIf RampRateTime >= 10 Then
'        FormatRAMRRT = Format(RampRateTime, "00.0000")
'    Else
'        FormatRAMRRT = Format(RampRateTime, "0.0000")
'    End If
'End Function

⌨️ 快捷键说明

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