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

📄 calculator.frm

📁 仿xp的计算器功能和普通计算器的功能一样
💻 FRM
📖 第 1 页 / 共 3 页
字号:

Private Sub cmdsqrt_Click()

    If LenB(display.Text) = 0 Then
        display.Text = vbNullString
    Else 'NOT LENB(DISPLAY.TEXT)...
        display.Text = Sqr(display.Text)
        lbl_app.Text = "Sq"
        lbl_app.ForeColor = vbBlack
    End If

End Sub

Private Sub cmdsqrt_MouseOver()

    cmdsqrt.ToolTipText = "Square Root"

End Sub

Private Sub cmdsqrt_MouseUp(Button As Integer, _
                            Shift As Integer, _
                            X As Single, _
                            Y As Single)

    Me.SetFocus

End Sub

Private Sub Command1_Click()

    screen2 = Val(display.Text)
    If operator = "+" Then
        display.Text = (screen1 + screen2)
    End If
    If operator = "-" Then
        display.Text = (screen1 - screen2)
    End If
    If operator = "/" Then
        If screen2 <> 0 Then
            display.Text = (screen1 / screen2)
        End If
    End If
    If operator = "x" Then
        display.Text = (screen1 * screen2)
    End If
    '<:-) Auto-inserted With End...With Structure
    With display
        If .Text < 0 Then
            If .Text > -1 Then
                .Text = "-0" & Abs(.Text) '在计算时如果小于1那小数点前就没0
            End If
        End If
    End With 'display
    '<:-) Auto-inserted With End...With Structure
    With display
        If .Text > 0 Then
            If .Text < 1 Then
                .Text = "0" & Abs(.Text) '在计算时如果小于1那小数点前就没0
            End If
        End If
    End With 'display
    'screen1 = Val(display.Text)

End Sub

Private Sub Command1_KeyDown(KeyCode As Integer, _
                             Shift As Integer)

'<:-) :WARNING: Large Code procedure (224 lines of code)
'<:-) It is recommended that you try to break it into smaller procedures

    If KeyCode = vbKeyDecimal Then
        cmdpoint_Click
    End If
    If KeyCode = vbKeyDivide Then
        cmddivide_Click
    End If
    If KeyCode = vbKeyMultiply Then
        cmdmultiply_Click
    End If
    If KeyCode = vbKeySubtract Then
        cmdminus_Click
    End If
    If KeyCode = vbKeyAdd Then
        cmdplus_Click
    End If
    If KeyCode = vbKeyBack Then
        If LenB(display.Text) = 0 Then
            display.Text = vbNullString
        Else 'NOT LENB(DISPLAY.TEXT)...
            display.Text = Mid$(display.Text, 1, Len(display.Text) - 1)
        End If
    End If
    If KeyCode = vbKeyNumpad0 Then
        With display
            If .Text = "0" Then
                .Text = vbNullString
                .Text = "0"
            Else 'NOT .TEXT...
                .Text = .Text & "0"
            End If
        End With 'display
    End If
    If KeyCode = vbKeyNumpad1 Then
        With display
            If .Text = "0" Then
                .Text = vbNullString
                .Text = "1"
            Else 'NOT .TEXT...
                .Text = .Text & "1"
            End If
        End With 'display
    End If
    If KeyCode = vbKeyNumpad2 Then
        With display
            If .Text = "0" Then
                .Text = vbNullString
                .Text = "2"
            Else 'NOT .TEXT...
                .Text = .Text & "2"
            End If
        End With 'display
    End If
    If KeyCode = vbKeyNumpad3 Then
        With display
            If .Text = "0" Then
                .Text = vbNullString
                .Text = "3"
            Else 'NOT .TEXT...
                .Text = .Text & "3"
            End If
        End With 'display
    End If
    If KeyCode = vbKeyNumpad4 Then
        With display
            If .Text = "0" Then
                .Text = vbNullString
                .Text = "4"
            Else 'NOT .TEXT...
                .Text = .Text & "4"
            End If
        End With 'display
    End If
    If KeyCode = vbKeyNumpad5 Then
        With display
            If .Text = "0" Then
                .Text = vbNullString
                .Text = "5"
            Else 'NOT .TEXT...
                .Text = .Text & "5"
            End If
        End With 'display
    End If
    If KeyCode = vbKeyNumpad6 Then
        With display
            If .Text = "0" Then
                .Text = vbNullString
                .Text = "6"
            Else 'NOT .TEXT...
                .Text = .Text & "6"
            End If
        End With 'display
    End If
    If KeyCode = vbKeyNumpad7 Then
        With display
            If .Text = "0" Then
                .Text = vbNullString
                .Text = "7"
            Else 'NOT .TEXT...
                .Text = .Text & "7"
            End If
        End With 'display
    End If
    If KeyCode = vbKeyNumpad8 Then
        With display
            If .Text = "0" Then
                .Text = vbNullString
                .Text = "8"
            Else 'NOT .TEXT...
                .Text = .Text & "8"
            End If
        End With 'display
    End If
    If KeyCode = vbKeyNumpad9 Then
        With display
            If .Text = "0" Then
                .Text = vbNullString
                .Text = "9"
            Else 'NOT .TEXT...
                .Text = .Text & "9"
            End If
        End With 'display
    End If
    If KeyCode = vbKey0 Then
        With display
            If .Text = "0" Then
                .Text = vbNullString
                .Text = "0"
            Else 'NOT .TEXT...
                .Text = .Text & "0"
            End If
        End With 'display
    End If
    If KeyCode = vbKey1 Then
        With display
            If .Text = "0" Then
                .Text = vbNullString
                .Text = "1"
            Else 'NOT .TEXT...
                .Text = .Text & "1"
            End If
        End With 'display
    End If
    If KeyCode = vbKey2 Then
        With display
            If .Text = "0" Then
                .Text = vbNullString
                .Text = "2"
            Else 'NOT .TEXT...
                .Text = .Text & "2"
            End If
        End With 'display
    End If
    If KeyCode = vbKey3 Then
        With display
            If .Text = "0" Then
                .Text = vbNullString
                .Text = "3"
            Else 'NOT .TEXT...
                .Text = .Text & "3"
            End If
        End With 'display
    End If
    If KeyCode = vbKey4 Then
        With display
            If .Text = "0" Then
                .Text = vbNullString
                .Text = "4"
            Else 'NOT .TEXT...
                .Text = .Text & "4"
            End If
        End With 'display
    End If
    If KeyCode = vbKey5 Then
        With display
            If .Text = "0" Then
                .Text = vbNullString
                .Text = "5"
            Else 'NOT .TEXT...
                .Text = .Text & "5"
            End If
        End With 'display
    End If
    If KeyCode = vbKey6 Then
        With display
            If .Text = "0" Then
                .Text = vbNullString
                .Text = "6"
            Else 'NOT .TEXT...
                .Text = .Text & "6"
            End If
        End With 'display
    End If
    If KeyCode = vbKey7 Then
        With display
            If .Text = "0" Then
                .Text = vbNullString
                .Text = "7"
            Else 'NOT .TEXT...
                .Text = .Text & "7"
            End If
        End With 'display
    End If
    If KeyCode = vbKey8 Then
        With display
            If .Text = "0" Then
                .Text = vbNullString
                .Text = "8"
            Else 'NOT .TEXT...
                .Text = .Text & "8"
            End If
        End With 'display
    End If
    If KeyCode = vbKey9 Then
        With display
            If .Text = "0" Then
                .Text = vbNullString
                .Text = "9"
            Else 'NOT .TEXT...
                .Text = .Text & "9"
            End If
        End With 'display
    End If

End Sub

Private Sub Copy_Click()

    display.SelStart = 0
    display.SelLength = Len(display.Text)
    Clipboard.Clear
    Clipboard.SetText display.SelText

End Sub

Private Sub Default_Click()

    display.BackColor = vbWhite
    display.ForeColor = vbBlack
    Image1.Picture = LoadPicture("")

End Sub

Private Sub Digital_Click()

    Image1.Picture = LoadPicture(App.Path & "\backdigital.gif")

End Sub

Private Sub display_Change()

    If Len(display.Text) <= 0 Then
        display.Text = "0"
    End If

End Sub

Private Sub display_Click()

    Command1.SetFocus

End Sub

Private Sub display_GotFocus()

    Command1.SetFocus

End Sub

Private Sub Exit_Click()

    End

End Sub

Private Sub Form_KeyUp(KeyCode As Integer, _
                       Shift As Integer)

'<:-) :WARNING: Large Control procedure (69 lines of code)
'<:-) This is a User Interactive Control Procedures, it is good practice to create procedures to seperate funtionality.

    If KeyCode = vbKeyBack Then
        If LenB(display.Text) = 0 Then
            display.Text = vbNullString
        Else 'NOT LENB(DISPLAY.TEXT)...
            display.Text = Mid$(display.Text, 1, Len(display.Text) - 1)
        End If
    End If
    If KeyCode = vbKeyNumpad0 Then
        display.Text = display.Text & "0"
    End If
    If KeyCode = vbKeyNumpad1 Then
        display.Text = display.Text & "1"
    End If
    If KeyCode = vbKeyNumpad2 Then
        display.Text = display.Text & "2"
    End If
    If KeyCode = vbKeyNumpad3 Then
        display.Text = display.Text & "3"
    End If
    If KeyCode = vbKeyNumpad4 Then
        display.Text = display.Text & "4"
    End If
    If KeyCode = vbKeyNumpad5 Then
        display.Text = display.Text & "5"
    End If
    If KeyCode = vbKeyNumpad6 Then
        display.Text = display.Text & "6"
    End If
    If KeyCode = vbKeyNumpad7 Then
        display.Text = display.Text & "7"
    End If
    If KeyCode = vbKeyNumpad8 Then
        display.Text = display.Text & "8"
    End If
    If KeyCode = vbKeyNumpad9 Then
        display.Text = display.Text & "9"
    End If
    If KeyCode = vbKey0 Then
        display.Text = display.Text & "0"
    End If
    If KeyCode = vbKey1 Then
        display.Text = display.Text & "1"
    End If
    If KeyCode = vbKey2 Then
        display.Text = display.Text & "2"
    End If
    If KeyCode = vbKey3 Then
        display.Text = display.Text & "3"
    End If
    If KeyCode = vbKey4 Then
        display.Text = display.Text & "4"
    End If
    If KeyCode = vbKey5 Then
        display.Text = display.Text & "5"
    End If
    If KeyCode = vbKey6 Then
        display.Text = display.Text & "6"
    End If
    If KeyCode = vbKey7 Then
        display.Text = display.Text & "7"
    End If
    If KeyCode = vbKey8 Then
        display.Text = display.Text & "8"
    End If
    If KeyCode = vbKey9 Then
        display.Text = display.Text & "9"
    End If

End Sub

Private Sub Form_Load()

    standard.Checked = True
    X = "US Soft"
    memshoworhide.Checked = False
    tmp.Visible = False
    memsux = False
    Me.Width = 3945
    Me.Height = 4035

End Sub

Private Sub grouping_Click()

    MsgBox ("Under Construction"), vbInformation, X

End Sub

Private Sub Helptopic_Click()

    MsgBox ("Under Construction"), vbInformation, X

End Sub

Private Sub lbl_app_Click()

    Command1.SetFocus

End Sub

Private Sub lbl_app_GotFocus()

    Command1.SetFocus

End Sub

Private Sub memshoworhide_Click()

    If memshoworhide.Checked Then
        memshoworhide.Checked = False
        tmp.Visible = False
    ElseIf Not memshoworhide.Checked Then 'MEMSHOWORHIDE.CHECKED = FALSE/0
        memshoworhide.Checked = True
        tmp.Visible = True
    End If

End Sub

Private Sub Paste_Click()

    With display
        If .Text = "0" Then
            .Text = Empty
            .Text = Clipboard.GetText
        End If
    End With 'display

End Sub

Private Sub Scientific_Click()

    MsgBox ("Under Construction"), vbInformation, X

End Sub

Private Sub standard_Click()

    If standard.Checked Then
        standard.Checked = False
    ElseIf Not standard.Checked Then 'STANDARD.CHECKED = FALSE/0
        standard.Checked = True
    End If

End Sub

Private Sub Timer1_Timer()

Dim str  As String

    '<:-) :SUGGESTION: (2) Replace with in-line call to calculation/function which assigns it a value.
Dim Str1 As String
    '<:-) :SUGGESTION: (2) Replace with in-line call to calculation/function which assigns it a value.
    With Me
        Str1 = Mid$(.Caption, 1, 1)
        str = Mid$(.Caption, 2, Len(.Caption) - 1)
        .Caption = str + Str1
    End With 'Me

End Sub

Private Sub XPButton1cmdzero_Click()

    Command1.SetFocus
    If display.Text = "0" Then
        display.Text = vbNullString
        display.Text = "0"
    Else 'NOT DISPLAY.TEXT...
        display.Text = display.Text & "0"
    End If

End Sub

Private Sub XPButton1cmdzero_GotFocus()

    Command1.SetFocus

End Sub

Private Sub XPButton1cmdzero_MouseOver()

    XPButton1cmdzero.ToolTipText = XPButton1cmdzero.Caption

End Sub

''Private Sub cmdx_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
''
''
''Me.SetFocus
''End Sub
''

':)Code Fixer V3.0.9 (2006-12-2 23:31:16) 12 + 1005 = 1017 Lines Thanks Ulli for inspiration and lots of code.

⌨️ 快捷键说明

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