Public fir As Double
Public p As String
Public sec As Double
Private Sub callc_click()
strWinDir = Environ("windir")
Shell (strWinDir & "\system32\calc.exe"), vbNormalFocus
End SubPrivate Sub Form_Load()
Form2.Show
Form1.Hide
End SubPrivate Sub how_Click()
Dim value As Integer
value = MsgBox("±¾³ÌÐòÓÃVB6.0д³É£¬Ëü²»½ö¿ÉÒÔ½øÐÐÒ»°ãµÄÊýÖµ¼ÆË㣬»¹¿ÉÒÔÏÔʾÈÕÆÚ,Ä㻹¿ÉÒÔµ÷ÓÃWindows×Ô´øµÄ¼ÆËãÆ÷£¬¡°¹ØÓÚ¡±Öл¹¼¯³Éʱ¼äÈÕÆÚÏÔʾºÍÃë±í¹¦ÄÜ¡£", 0, "˵Ã÷")End Sub
Private Sub about_Click()
form3.Show
End Sub
Private Sub Command1_Click()
If Text1.Text = "" Then
       Text1.Text = "7"
    Else
       Text1.Text = Text1.Text + "7"
    End If
End SubPrivate Sub Command10_Click()
    If Text1.Text <> "" Then
        fir = Val(Text1.Text)
        Text1.Text = ""
        p = "/"
    Else
       MsgBox "&#196;ú&#205;ü&#188;&#199;&#202;&#228;&#200;&#235;&#202;&#253;&#190;&#221;&#193;&#203;&#163;&#161;", 16, "&#190;&#175;&#184;&#230;&#180;°&#191;&#218;"
    End If
End SubPrivate Sub Command11_Click()
If Text1.Text = "" Then
       Text1.Text = "1"
    Else
       Text1.Text = Text1.Text + "1"
    End If
End SubPrivate Sub Command12_Click()
    If Text1.Text = "" Then
       Text1.Text = "2"
    Else
       Text1.Text = Text1.Text + "2"
    End If
End SubPrivate Sub Command13_Click()
If Text1.Text = "" Then
       Text1.Text = "3"
    Else
       Text1.Text = Text1.Text + "3"
    End IfEnd SubPrivate Sub Command14_Click()
If Text1.Text <> "" Then
     fir = Val(Text1.Text)
     Text1.Text = ""
     p = "-"
  Else
     MsgBox "&#196;ú&#205;ü&#188;&#199;&#202;&#228;&#200;&#235;&#202;&#253;&#190;&#221;&#193;&#203;&#163;&#161;", 16, "&#190;&#175;&#184;&#230;&#180;°&#191;&#218;"
  End If
End SubPrivate Sub Command15_Click()
   If Text1.Text = "" Then
      MsgBox "&#195;&#187;&#211;&#208;&#202;&#253;&#190;&#221;&#191;&#201;&#199;&#229;&#179;&#253;&#163;&#161;", , "&#190;&#175;&#184;&#230;&#180;°&#191;&#218;"
      Exit Sub
   Else
      Text1.Text = ""
   End If
End SubPrivate Sub Command16_Click()
If Text1.Text = "" Then
       Text1.Text = "0"
    Else
       Text1.Text = Text1.Text + "0"
    End If
End SubPrivate Sub Command17_Click()
If InStr(Text1.Text, ".") = 0 Then
      If Text1.Text = "" Then
         Text1.Text = "."
      Else
         Text1.Text = Text1.Text + "."
      End If
   End If
End SubPrivate Sub Command18_Click()
   If Text1.Text <> "" Then
      fir = Val(Text1.Text)
      Text1.Text = ""
      p = "+"
   Else
      MsgBox "&#196;ú&#205;ü&#188;&#199;&#202;&#228;&#200;&#235;&#202;&#253;&#190;&#221;&#193;&#203;&#163;&#161;", 16, "&#190;&#175;&#184;&#230;&#180;°&#191;&#218;"
   End If
End SubPrivate Sub Command19_Click()
   If p = "jc" Then
      fir = Val(Text1.Text)
   Else
      sec = Val(Text1.Text)
   End If
   If Text1.Text = "" And p <> "!" Then
      MsgBox "&#205;ü&#188;&#199;&#202;&#228;&#200;&#235;&#202;&#253;&#190;&#221;&#193;&#203;&#163;&#161;", 16, "&#190;&#175;&#184;&#230;&#180;°&#191;&#218;"
   Else
      Select Case p
         Case "+"
           Text1.Text = Str$(fir + sec)
         Case "-"
           Text1.Text = Str$(fir - sec)
         Case "*"
           Text1.Text = Str$(fir * sec)
         Case "/"
           If sec = 0 Then
              MsgBox "&#193;&#227;&#178;&#187;&#196;&#220;×&#246;&#179;&#253;&#202;&#253;&#163;&#161;", 16, "&#190;&#175;&#184;&#230;&#180;°&#191;&#218;"
              Exit Sub
           End If
           Text1.Text = Str$(fir / sec)
         Case "%"
           If sec = 0 Then
              MsgBox "&#193;&#227;&#178;&#187;&#196;&#220;×&#246;&#179;&#253;&#202;&#253;&#163;&#161;", 16, "&#190;&#175;&#184;&#230;&#180;°&#191;&#218;"
              Exit Sub
           End If
           If Int(fir) <> fir Or Int(sec) <> sec Then
              MsgBox "&#214;&#187;&#211;&#208;&#213;&#251;&#202;&#253;&#178;&#197;&#196;&#220;&#189;&#248;&#208;&#208;&#213;&#251;&#179;&#253;&#212;&#203;&#203;&#227;", 16, "&#190;&#175;&#184;&#230;&#180;°&#191;&#218;"
              Exit Sub
           Else
              Text1.Text = Str$(fir \ sec)
           End If
         Case "cf"
            Text1.Text = Str$(fir ^ sec)
         Case "kf"
            Text1.Text = Str$(fir ^ (1 / sec))
     End Select
  End If
End Sub
Private Sub Command20_Click()
yer = Year(Now)
mnth = Month(Now)
dy = Day(Now)
    Select Case Weekday(Now)
         Case 1
            wkd$ = "&#200;&#213;"
         Case 2
            wkd$ = "&#210;&#187;"
         Case 3
            wkd$ = "&#182;&#254;"
         Case 4
            wkd$ = "&#200;&#253;"
         Case 5
            wkd$ = "&#203;&#196;"
         Case 6
            wkd$ = "&#206;&#229;"
         Case 7
            wkd$ = "&#193;ù"
    End Select
Text1.Text = Str$(yer) + "&#196;ê" + Str$(mnth) + "&#212;&#194;" + Str$(dy) + "&#200;&#213; &#208;&#199;&#198;&#218;" + wkd$
End SubPrivate Sub Command3_Click()
If Text1.Text = "" Then
       Text1.Text = "9"
    Else
       Text1.Text = Text1.Text + "9"
    End If
End Sub
Private Sub Command4_Click()
    If Text1.Text <> "" Then
        fir = Val(Text1.Text)
        Text1.Text = ""
        p = "/"
    Else
       MsgBox "&#196;ú&#205;ü&#188;&#199;&#202;&#228;&#200;&#235;&#202;&#253;&#190;&#221;&#193;&#203;&#163;&#161;", 16, "&#190;&#175;&#184;&#230;&#180;°&#191;&#218;"
    End If
End SubPrivate Sub Command5_Click()
    If Text1.Text <> "" Then
        fir = Val(Text1.Text)
        Text1.Text = ""
        p = "kf"
    Else
       MsgBox "&#196;ú&#205;ü&#188;&#199;&#202;&#228;&#200;&#235;&#202;&#253;&#190;&#221;&#193;&#203;&#163;&#161;", 16, "&#190;&#175;&#184;&#230;&#180;°&#191;&#218;"
    End If
End SubPrivate Sub Command6_Click()
If Text1.Text = "" Then
       Text1.Text = "4"
    Else
       Text1.Text = Text1.Text + "4"
    End IfEnd SubPrivate Sub Command7_Click()
If Text1.Text = "" Then
       Text1.Text = "5"
    Else
       Text1.Text = Text1.Text + "5"
    End IfEnd SubPrivate Sub Command8_Click()
If Text1.Text = "" Then
       Text1.Text = "6"
    Else
       Text1.Text = Text1.Text + "6"
    End IfEnd SubPrivate Sub Command9_Click()
If Text1.Text <> "" Then
        fir = Val(Text1.Text)
        Text1.Text = ""
        p = "*"
    Else
       MsgBox "&#196;ú&#205;ü&#188;&#199;&#202;&#228;&#200;&#235;&#202;&#253;&#190;&#221;&#193;&#203;&#163;&#161;", 16, "&#190;&#175;&#184;&#230;&#180;°&#191;&#218;"
    End IfEnd Sub
Private Sub Command2_Click()
      If Text1.Text = "" Then
       Text1.Text = "8"
    Else
       Text1.Text = Text1.Text + "8"
    End IfEnd Sub

解决方案 »

  1.   

    我也是的哈 我用了2中solution都还是你的那中效果,和你一起探讨 [email protected]
      

  2.   

    很簡單吧,每次按鍵時都都要先判斷是按的是運算符還是數字鍵,
    如果是數字鍵則判斷前一次是按的什么鍵。
    如果前一次是運算符號或者enter鍵,則清除原來的數字顯示。
    如果前一次按的是數字鍵,則本次的數字加在后面。
    如果本次按的是運算符,則馬上計算出運算結果,并顯示出來。
    最后還要記錄下本次的按鍵
    偽代碼:
    IF 本次按的是數字鍵 then
        IF 上次按的是運算符 then
            清除原來的數字顯示
        else
            數字加在后面
        end
    else if 本次按的是運算符 then
        計算出運算結果,并顯示出來
    else
        非法的按鍵,發出beep,退出過程,不做其它反應
    end if
    最后還要記錄下本次的按鍵