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

📄 frmeditnumber.frm

📁 AD9954源码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmEditNumber 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "Edit Numeric Value"
   ClientHeight    =   2070
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4575
   BeginProperty Font 
      Name            =   "MS Sans Serif"
      Size            =   8.25
      Charset         =   0
      Weight          =   700
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "frmEditNumber.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2070
   ScaleWidth      =   4575
   ShowInTaskbar   =   0   'False
   StartUpPosition =   1  'CenterOwner
   Begin VB.TextBox txtDecVal 
      Alignment       =   1  'Right Justify
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   13.5
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   405
      Left            =   1200
      MaxLength       =   5
      TabIndex        =   8
      Text            =   "00000"
      Top             =   240
      Width           =   1095
   End
   Begin VB.Frame Frame1 
      Height          =   1215
      Left            =   120
      TabIndex        =   2
      Top             =   720
      Width           =   2895
      Begin VB.TextBox txtBinVal 
         Alignment       =   1  'Right Justify
         Height          =   285
         Index           =   1
         Left            =   240
         MaxLength       =   2
         MultiLine       =   -1  'True
         TabIndex        =   5
         Text            =   "frmEditNumber.frx":000C
         Top             =   720
         Width           =   975
      End
      Begin VB.TextBox txtHexVal 
         Alignment       =   1  'Right Justify
         Height          =   285
         Left            =   1560
         MaxLength       =   4
         TabIndex        =   4
         Text            =   "0000"
         Top             =   240
         Width           =   615
      End
      Begin VB.TextBox txtBinVal 
         Alignment       =   2  'Center
         Height          =   285
         Index           =   0
         Left            =   1200
         MaxLength       =   8
         MultiLine       =   -1  'True
         TabIndex        =   3
         Text            =   "frmEditNumber.frx":0017
         Top             =   720
         Width           =   975
      End
      Begin VB.Label lblHex 
         Caption         =   "Hex"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   2280
         TabIndex        =   7
         Top             =   240
         Width           =   375
      End
      Begin VB.Label lblBin 
         Caption         =   "Bin"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   2280
         TabIndex        =   6
         Top             =   720
         Width           =   375
      End
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "&OK"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3240
      TabIndex        =   1
      Top             =   120
      Width           =   1215
   End
   Begin VB.CommandButton cmdCancel 
      Caption         =   "Cancel"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   3240
      TabIndex        =   0
      Top             =   600
      Width           =   1215
   End
   Begin VB.Label Label1 
      Alignment       =   1  'Right Justify
      Caption         =   "Value:"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   120
      TabIndex        =   10
      Top             =   300
      Width           =   975
   End
   Begin VB.Label lblDec 
      Caption         =   "Dec"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   12
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   2400
      TabIndex        =   9
      Top             =   300
      Width           =   615
   End
End
Attribute VB_Name = "frmEditNumber"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim PhaseOffArray() As Double
Private EditBox As TextBox
Dim NumPhaseVals As Integer
Dim MaxDecVal As Integer
Dim NumDecDigits As Integer
Dim NumHexDigits As Integer
Dim NumBinDigits As Integer

'Returns the decimal seperator in either ascii code or
'the character
Private Function GetDecSeparator(ByVal RetAsciiCode As Boolean) As Variant
    If RetAsciiCode Then
        GetDecSeparator = Asc(Mid(Format(0, "Fixed"), 2, 1))
    Else
        GetDecSeparator = Mid(Format(0, "Fixed"), 2, 1)
    End If
End Function

Private Sub UpdateVals(ByVal value As Variant)
    Dim POBin As String
    Dim OutFreqval As Variant
        
    'Decimal value textbox
    If Not (ActiveControl Is txtDecVal) Then
        txtDecVal.Text = Format(value, String(NumDecDigits, "0"))
        txtDecVal.Text = String(NumDecDigits - Len(txtDecVal.Text), "0") & txtDecVal.Text
        txtDecVal.Refresh
    End If
    
    'Hex textbox
    If Not (ActiveControl Is txtHexVal) Then
        'Update this box because it is not currently active
        txtHexVal.Text = cbaseHex(value, NumHexDigits)
        txtHexVal.Text = String(NumHexDigits - Len(txtHexVal.Text), "0") & txtHexVal.Text
        txtHexVal.Refresh
    End If
    
    'Generate a binary string representing the phase offset value
    POBin = cbaseDec2Bin(value, NumBinDigits)
    
    'Binary TextBoxes
    If Not (ActiveControl Is txtBinVal) Then
        If NumBinDigits <= 8 Then
            txtBinVal(0).Text = Right(POBin, NumBinDigits)
            txtBinVal(0).Refresh
        Else
            txtBinVal(0).Text = Right(POBin, 8)
            txtBinVal(1).Text = Left(POBin, NumBinDigits - 8)
            txtBinVal(0).Refresh
            txtBinVal(1).Refresh
        End If
    End If
End Sub

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.Text = txtDecVal.Text
    
    Me.Hide
        
End Sub

Private Sub Form_Activate()
    'Set the decimal value
    txtDecVal.Text = EditBox.Text
    
    txtDecVal.SetFocus
    
    'Update all other displays
    UpdateVals 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 Bits2Edit As Integer, Optional Title)
    'Calculate the maximum value that can be entered
    MaxDecVal = cbaseBinS2Dec(String(Bits2Edit, "1"))
    
    'Get the number of digits to allow to be typed in
    NumDecDigits = Len(CStr(MaxDecVal))
    txtDecVal.MaxLength = NumDecDigits
    NumHexDigits = Len(Hex(MaxDecVal))
    txtHexVal.MaxLength = NumHexDigits
    NumBinDigits = Bits2Edit
    If Bits2Edit <= 8 Then
        txtBinVal(1).Visible = False
        txtBinVal(0).MaxLength = Bits2Edit
    Else
        txtBinVal(1).MaxLength = Bits2Edit - 8
    End If
    
    Set EditBox = Tbox
    
    'Set the title of the dialog
    If Not IsMissing(Title) Then
        Me.Caption = Title
    End If
    
    Me.Show 1
    
    'Release the pointer to the edit box
    Set EditBox = Nothing
    
    'Unload the form
    Unload Me

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 BinVal As Variant
    Dim sTWBinVal As String
    
    'Fill any missing digits in with Zeros
    If Index = 0 Then
        If NumBinDigits <= 8 Then
            txtBinVal(Index).Text = String(NumBinDigits - Len(txtBinVal(Index).Text), "0") & txtBinVal(Index).Text
        Else
            txtBinVal(Index).Text = String(8 - Len(txtBinVal(Index).Text), "0") & txtBinVal(Index).Text
        End If
    ElseIf Index = 1 Then
        If NumBinDigits > 8 Then
            txtBinVal(Index).Text = String((NumBinDigits - 8) - Len(txtBinVal(Index).Text), "0") & txtBinVal(Index).Text
        End If
    End If
    
    'If something non numeric is entered then zero the control
    If Not IsNumeric(txtBinVal(Index).Text) Then
        If Index = 0 Then
            If NumBinDigits <= 8 Then
                txtBinVal(Index).Text = String(NumBinDigits, "0")
            Else
                txtBinVal(Index).Text = String(8, "0")
            End If
        ElseIf Index = 1 Then
            If NumBinDigits > 8 Then
                txtBinVal(Index).Text = String((NumBinDigits - 8), "0")
            End If
        End If
    End If
    
    'Get the value of the textbox
    BinVal = cbaseBinS2Dec(txtBinVal(1).Text & txtBinVal(0).Text)
        
    'Update the other textboxes
    UpdateVals (BinVal)
    
    '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 DecVal As Long
    
    'If something non numeric is entered then zero the control
    If Not IsNumeric(txtDecVal.Text) Then
        txtDecVal.Text = Format(0, String(NumDecDigits, "0"))
    End If
    
    'Get the value of the textbox
    DecVal = CLng(txtDecVal.Text)
    
    If DecVal <= MaxDecVal Then
        'Display the new value
        txtDecVal.Text = Format(DecVal, String(NumDecDigits, "0"))
    Else
        MsgBox "The decimal value should not exceed " & MaxDecVal & "."
        DecVal = MaxDecVal
        txtDecVal.Text = Format(DecVal, String(NumDecDigits, "0"))
        Cancel = True
    End If
    
    'Update the other textboxes
    UpdateVals 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
        
    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(txtHexVal.Text)
    
    If HexVal <= MaxDecVal Then
        'Display the new value
        txtHexVal.Text = cbaseHex(HexVal, NumHexDigits)
    Else
        MsgBox "The hex value should not exceed " & cbaseHex(MaxDecVal, NumHexDigits) & "."
        HexVal = MaxDecVal
        txtHexVal.Text = cbaseHex(HexVal, NumHexDigits)
        Cancel = True
    End If
    
    'Update the other textboxes
    UpdateVals (HexVal)
    
    'Set the focus back to the ok button
    cmdOK.SetFocus
End Sub

⌨️ 快捷键说明

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