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

📄 form1.frm

📁 具有windows计算器所有功能的计算器
💻 FRM
📖 第 1 页 / 共 3 页
字号:
          Text1.Text = Space(37 - Len(LTrim(Text1.Text))) & "-" & LTrim(Text1.Text)
        Else
          Text1.Text = Space(39 - Len(Trim(Text1.Text))) & Right(Text1.Text, Len(Trim(Text1.Text)) - 1)
        End If
    Else
       If flag = True Then
         Text1.Text = Space(36) & Command1(Index).Caption & "."
       Else
       Text1.Text = Space(35) & LTrim(Text1.Text) & Command1(Index).Caption
       End If
       flag = True
    End If
End If
flag3 = True
FLAG2 = False

End Sub


Private Sub Command4_Click(Index As Integer)
 flag3 = False
 Select Case Index
    Case 0
      Label1.Caption = " "
      Text2.Text = Space(36) & "0" & "."
    Case 1
      Text1.Text = Text2.Text
    Case 2
      Text2.Text = Text1.Text
      Label1.Caption = " M"
    Case 3
      Label1.Caption = " M"
      If FLAG2 = False Then
       Text2.Text = Val(Text2.Text) + Val(Text1.Text)
      Else
        FLAG2 = True
      End If
End Select

If Left(Text1.Text, 1) = "." Then
    Text1.Text = Space(37 - Len(Text1.Text)) & "0" & Text1.Text
ElseIf Left(Text1.Text, 2) = "-." Then
   Text1.Text = Space(37 - Len(Text1.Text)) & Replace(Text1.Text, "-", "-0")
End If
If Val(Text1.Text) = Fix(Val(Text1.Text)) Then
   If Val(Text1.Text) < 0 Then
     Text1.Text = Space(37 - Len(Str(Val(Text1.Text)))) & Val(Text1.Text) & "."
   Else
     Text1.Text = Space(38 - Len(Str(Val(Text1.Text)))) & Val(Text1.Text) & "."
   End If
Else
  Text1.Text = Space(38 - Len(Trim(Text1.Text))) & Trim(Text1.Text)
End If
 FLAG2 = True
End Sub

Private Sub Command5_Click(Index As Integer)
Select Case Index
  Case 0
    If (Len(LTrim(Text1.Text)) = 2 And Left(Trim(Text1.Text), 1) <> "-") Or (Len(LTrim(Text1.Text)) = 3 And Left(Trim(Text1.Text), 1) = "-") Then
      Text1.Text = Space(36) & "0" & "."
    ElseIf Right(Trim(Text1.Text), 1) = "." Then
      Text1.Text = Space(39 - Len(LTrim(Text1.Text))) & Left(LTrim(Text1.Text), Len(LTrim(Text1.Text)) - 2) & "."
    Else
      Text1.Text = Space(39 - Len(LTrim(Text1.Text))) & Left(LTrim(Text1.Text), Len(LTrim(Text1.Text) - 1))
    End If
 Case 1
   Text3.Text = Text1.Text
   Text1.Text = Space(36) & "0."
 Case 2
    js = True
    Text3.Text = ""
    Text5.Text = ""
    Text1.Text = Space(36) & "0."
 End Select
End Sub

Private Sub Command6_Click(Index As Integer)
flag3 = False
If tag1 = False Then
   Select Case Index
     Case 0
        m = 0
     Case 1
        m = 1
      Case 2
        m = 2
      Case 3
        m = 3
      Case 4
       
        If Val(Text1.Text) < 0 Then
            x = MsgBox("函数输入无效", , "错误提示")
        Else
            Text1.Text = Sqr(Val(Text1.Text))
        End If
     Case 6
    
        If Val(Text1.Text) = 0 Then
            x = MsgBox("除数不能为0", , "错误提示")
       Else
           Text1.Text = 1 / Val(Text1.Text)
       End If
   End Select
Else
   Select Case Index
      Case 0 To 3
        If js = False Then
            If m = 0 Then
                Text1.Text = Val(Text3.Text) / Val(Text1.Text)
             ElseIf m = 1 Then
                Text1.Text = Val(Text3.Text) * Val(Text1.Text)
            ElseIf m = 2 Then
                Text1.Text = Val(Text3.Text) - Val(Text1.Text)
            Else
                 Text1.Text = Val(Text3.Text) + Val(Text1.Text)
            End If
        Else
             Text3.Text = Text1.Text
        End If
     js = False
     Select Case Index
          Case 0
              m = 0
          Case 1
             m = 1
          Case 2
             m = 2
         Case 3
             m = 3
  End Select
     
 Case 4

   If Val(Text1.Text) < 0 Then
    x = MsgBox("函数输入无效", , "错误提示")
   Else
    Text1.Text = Sqr(Val(Text1.Text))
   End If
Case 5
   js = True
   Text1.Text = Val(Text5.Text) * Val(Text1.Text) / 100
Case 6
  
   If Val(Text1.Text) = 0 Then
     x = MsgBox("除数不能为0", , "错误提示")
   Else
    Text1.Text = 1 / Val(Text1.Text)
   End If
   
 Case 7
    js = True
    If Text3.Text = "  " Then
      Exit Sub
    Else
    Select Case m
      Case 0
        If Val(Text1.Text) = 0 Then
          x = MsgBox("除数不能为0", , "提示")
        Else
          Text1.Text = Val(Text3.Text) / Val(Text1.Text)
        End If
     Case 1
        Text1.Text = Val(Text1.Text) * Val(Text3.Text)
     Case 2
        Text1.Text = Val(Text3.Text) - Val(Text1.Text)
     Case 3
        Text1.Text = Val(Text3.Text) + Val(Text1.Text)
    End Select
    End If
  End Select
End If
If Left(Text1.Text, 1) = "." Then
  Text1.Text = Space(37 - Len(Text1.Text)) & "0" & Text1.Text
ElseIf Left(Text1.Text, 2) = "-." Then
  Text1.Text = Space(37 - Len(Text1.Text)) & Replace(Text1.Text, "-", "-0")
End If
If Val(Text1.Text) = Fix(Val(Text1.Text)) Then
  If Val(Text1.Text) < 0 Then
   Text1.Text = Space(37 - Len(Str(Val(Text1.Text)))) & Val(Text1.Text) & "."
  Else
   Text1.Text = Space(38 - Len(Str(Val(Text1.Text)))) & Val(Text1.Text) & "."
  End If
Else
  Text1.Text = Space(38 - Len(Trim(Text1.Text))) & Trim(Text1.Text)
End If
 Text3.Text = Text1.Text
 tag1 = False
If Index = 0 Or Index = 1 Or Index = 2 Or Index = 3 Then Text5.Text = Val(Text1.Text)

End Sub

Private Sub Form_Load()
js = True
flag = True
FLAG2 = True
flag3 = True
Text2.Text = Space(36) & "0" & "."
End Sub


Private Sub Timer1_Timer()
Text6.Text = Time
End Sub

Private Sub 标准型_Click()
Form1.Show
Form2.Hide
End Sub

Private Sub 复制_Click()
Clipboard.Clear
Clipboard.SetText (Text1.Text)
End Sub

Private Sub 科学型_Click()
Form2.Show
Form1.Hide
Text1.Text = Space(36) & "0."

End Sub

Private Sub 粘贴_Click()
Text1.Text = Val(Clipboard.GetText())
If Fix(Text1.Text) = Text1.Text Then Text1.Text = Space(37 - Len(Text1.Text)) & Text1.Text & "."
If Left(Text1.Text, 1) = "." Then
    Text1.Text = Space(37 - Len(Text1.Text)) & "0" & Text1.Text
ElseIf Left(Text1.Text, 2) = "-." Then
   Text1.Text = Space(37 - Len(Text1.Text)) & Replace(Text1.Text, "-", "-0")
End If
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
  Dim i As Single
   If KeyAscii = Asc(".") Then
        i = 11
         Command1_Click (i)
         Beep
   ElseIf KeyAscii = Asc("0") Then
        i = 0
         Command1_Click (i)
         Beep
   ElseIf KeyAscii = Asc("1") Then
        i = 1
          Command1_Click (i)
          Beep
   ElseIf KeyAscii = Asc("2") Then
        i = 2
          Command1_Click (i)
        Beep
   ElseIf KeyAscii = Asc("3") Then
        i = 3
          Command1_Click (i)
          Beep
   ElseIf KeyAscii = Asc("4") Then
        i = 4
          Command1_Click (i)
          Beep
   ElseIf KeyAscii = Asc("5") Then
        i = 5
          Command1_Click (i)
          Beep
   ElseIf KeyAscii = Asc("6") Then
        i = 6
          Command1_Click (i)
          Beep
   ElseIf KeyAscii = Asc("7") Then
        i = 7
          Command1_Click (i)
          Beep
   ElseIf KeyAscii = Asc("8") Then
        i = 8
          Command1_Click (i)
          Beep
   ElseIf KeyAscii = Asc("9") Then
        i = 9
          Command1_Click (i)
          Beep
   ElseIf KeyAscii = Asc("0") Then
        i = 0
          Command1_Click (i)
          Beep
   ElseIf KeyAscii = Asc("+") Then
        i = 3
          Command6_Click (i)
          Beep
   
   ElseIf KeyAscii = Asc("-") Then
        i = 2
          Command6_Click (i)
          Beep
   ElseIf KeyAscii = Asc("/") Then
        i = 0
          Command6_Click (i)
          Beep
 
   ElseIf KeyAscii = Asc("*") Then
        i = 1
          Command6_Click (i)
          Beep
   ElseIf KeyAscii = Asc("=") Then
        i = 7
          Command6_Click (i)
          Beep
    ElseIf KeyAscii = Asc("@") Then
        i = 4
          Command6_Click (i)
          Beep
   ElseIf KeyAscii = Asc("%") Then
        i = 5
          Command6_Click (i)
          Beep
 
   ElseIf KeyAscii = 65 Or KeyAscii = 97 Then
        i = 6
          Command6_Click (i)
          Beep
   ElseIf KeyAscii = 8 Then
        i = 0
          Command5_Click (i)
          Beep
    ElseIf KeyAscii = 101 Or KeyAscii = 69 Then
        i = 1
          Command5_Click (i)
          Beep
   ElseIf KeyAscii = 27 Then
        i = 2
          Command5_Click (i)
          Beep
 
   ElseIf KeyAscii = 99 Or KeyAscii = 67 Then
        i = 0
          Command4_Click (i)
          Beep
   ElseIf KeyAscii = 114 Or KeyAscii = 82 Then
        i = 1
          Command4_Click (i)
   ElseIf KeyAscii = 115 Or KeyAscii = 83 Then
        i = 2
          Command4_Click (i)
  ElseIf KeyAscii = 109 Or KeyAscii = 109 Then
        i = 3
          Command4_Click (i)
     ElseIf KeyAscii = 44 Then
        i = 10
          Command1_Click (i)
         Beep
   
   End If
End Sub

⌨️ 快捷键说明

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