那里有计算器得源代码,要全。
解决方案 »
- 高分求救,vb WebBrowser自动点击onClick
- VB中如何查自己的宽带IP
- 请问一下vb6怎样向某一页面发送url信息和接受来自其他页面发送过来的信息呢?请教,急,立刻给分
- 关于Listview控件。
- 请你帮忙看一下一个datagrid 控件输入的问题!
- 像写字板中的颜色按钮该用什么控件?
- 请大家帮帮忙呀!adocd与datagrid的问题
- 我是菜鸟帮帮我
- 数据字典 ?
- 编译后的文件会保留注释的内容吗?反编译的结果是汇编程序吗?
- 推荐:大量vb开发技巧
- 我在一个程序里用了一个listbox控件,我把它的style属性设为1,也就是让它成为复选框,怎么知道它里面的项是选中的呀(也就是哪项是前面打
http://www.developerfusion.com/show/160/Calculator
Begin VB.Form frmCalc
Caption = "Form2"
ClientHeight = 2895
ClientLeft = 60
ClientTop = 345
ClientWidth = 3150
LinkTopic = "Form2"
ScaleHeight = 2895
ScaleWidth = 3150
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Percent
Caption = "%"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Left = 2580
TabIndex = 18
ToolTipText = "Percent"
Top = 2340
Width = 480
End
Begin VB.CommandButton Operator
Caption = "="
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Index = 4
Left = 1980
TabIndex = 17
ToolTipText = "Answer"
Top = 2340
Width = 480
End
Begin VB.CommandButton Decimal
Caption = "."
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Left = 1260
TabIndex = 16
Top = 2340
Width = 480
End
Begin VB.CommandButton Number
Caption = "0"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Index = 0
Left = 60
TabIndex = 15
Top = 2340
Width = 1080
End
Begin VB.CommandButton Operator
Caption = "/"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Index = 0
Left = 2580
TabIndex = 14
ToolTipText = "Divide"
Top = 1740
Width = 480
End
Begin VB.CommandButton Operator
Caption = "X"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Index = 2
Left = 1980
TabIndex = 13
ToolTipText = "Multiply"
Top = 1740
Width = 480
End
Begin VB.CommandButton Number
Caption = "3"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Index = 3
Left = 1260
TabIndex = 12
Top = 1740
Width = 480
End
Begin VB.CommandButton Number
Caption = "2"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Index = 2
Left = 660
TabIndex = 11
Top = 1740
Width = 480
End
Begin VB.CommandButton Number
Caption = "1"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Index = 1
Left = 60
TabIndex = 10
Top = 1740
Width = 480
End
Begin VB.CommandButton Operator
Caption = "-"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Index = 3
Left = 2580
TabIndex = 9
ToolTipText = "Subtract"
Top = 1140
Width = 480
End
Caption = "+"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Index = 1
Left = 1980
TabIndex = 8
ToolTipText = "Add"
Top = 1140
Width = 480
End
Begin VB.CommandButton Number
Caption = "6"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Index = 6
Left = 1260
TabIndex = 7
Top = 1140
Width = 480
End
Begin VB.CommandButton Number
Caption = "5"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Index = 5
Left = 660
TabIndex = 6
Top = 1140
Width = 480
End
Begin VB.CommandButton Number
Caption = "4"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Index = 4
Left = 60
TabIndex = 5
Top = 1140
Width = 480
End
Begin VB.CommandButton CancelEntry
Caption = "CE"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Left = 2580
TabIndex = 4
ToolTipText = "Clear"
Top = 540
Width = 480
End
Begin VB.CommandButton Cancel
Caption = "C"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Left = 1980
TabIndex = 3
ToolTipText = "Undo last action"
Top = 540
Width = 480
End
Begin VB.CommandButton Number
Caption = "9"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Index = 9
Left = 1260
TabIndex = 2
Top = 540
Width = 480
End
Begin VB.CommandButton Number
Caption = "8"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Index = 8
Left = 660
TabIndex = 1
Top = 540
Width = 480
End
Begin VB.CommandButton Number
Caption = "7"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 480
Index = 7
Left = 60
TabIndex = 0
Top = 540
Width = 480
End
Begin VB.Label Readout
Alignment = 1 'Right Justify
BackColor = &H00FFFFFF&
BorderStyle = 1 'Fixed Single
Caption = "0."
BeginProperty Font
Name = "Tahoma"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 375
Left = 60
TabIndex = 19
Top = 45
Width = 3000
End
End
Attribute VB_Name = "frmCalc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim DecimalFlag As Integer ' Decimal point present yet?
Dim NumOps As Integer ' Number of operands.
Dim LastInput ' Indicate type of last keypress event.
Dim OpFlag ' Indicate pending operation.
Dim TempReadout' Click event procedure for C (cancel) key.
' Reset the display and initializes variables.
Private Sub Cancel_Click()
Readout = Format(0, "0.")
Op1 = 0
Op2 = 0
Form_Load
End SubPrivate Sub Cancel_KeyPress(KeyAscii As Integer)
PressKey (KeyAscii)
End Sub' Click event procedure for CE (cancel entry) key.
Private Sub CancelEntry_Click()
Readout = Format(0, "0.")
DecimalFlag = False
LastInput = "CE"
End SubPrivate Sub CancelEntry_KeyPress(KeyAscii As Integer)
PressKey (KeyAscii)
End Sub
Private Sub Command1_KeyPress(KeyAscii As Integer)
PressKey (KeyAscii)
End Sub
Private Sub Command2_KeyPress(KeyAscii As Integer)
PressKey (KeyAscii)
End Sub' Click event procedure for decimal point (.) key.
' If last keypress was an operator, initialize
' readout to "0." Otherwise, append a decimal
' point to the display.
Private Sub Decimal_Click()
If LastInput = "NEG" Then
Readout = Format(0, "-0.")
ElseIf LastInput <> "NUMS" Then
Readout = Format(0, "0.")
End If
DecimalFlag = True
LastInput = "NUMS"
End SubPrivate Sub Decimal_KeyPress(KeyAscii As Integer)
PressKey (KeyAscii)
End Sub
' Initialization routine for the form.
' Set all variables to initial values.
Private Sub Form_Load()
DecimalFlag = False
NumOps = 0
LastInput = "NONE"
OpFlag = " "
Readout = Format(0, "0.")
'Decimal.Caption = Format(0, ".")
End Sub' Click event procedure for number keys (0-9).
' Append new number to the number in the display.
Private Sub Number_Click(Index As Integer)
If LastInput <> "NUMS" Then
Readout = Format(0, ".")
DecimalFlag = False
End If
If DecimalFlag Then
Readout = Readout + Number(Index).Caption
Else
Readout = Left(Readout, InStr(Readout, Format(0, ".")) - 1) + Number(Index).Caption + Format(0, ".")
End If
If LastInput = "NEG" Then Readout = "-" & Readout
LastInput = "NUMS"
End SubPrivate Sub Number_KeyPress(Index As Integer, KeyAscii As Integer)
PressKey (KeyAscii)
End Sub
Sub PressKey(KeyAscii)
Dim Char As String
Char = Chr(KeyAscii)
Select Case Char
Case 1, 2, 3, 4, 5, 6, 7, 8, 9
Number_Click (Char)
Case "="
Operator_Click (4)
Case "+"
Operator_Click (1)
Case "-"
Operator_Click (3)
Case "/"
Operator_Click (0)
Case "*"
Operator_Click (2)
Case "%"
Percent_Click
Case "."
Decimal_Click
Case Else
Exit Sub
End Select
End Sub' Click event procedure for operator keys (+, -, x, /, =).
' If the immediately preceeding keypress was part of a
' number, increments NumOps. If one operand is present,
' set Op1. If two are present, set Op1 equal to the
' result of the operation on Op1 and the current
' input string, and display the result.
Private Sub Operator_Click(Index As Integer)
TempReadout = Readout
If LastInput = "NUMS" Then
NumOps = NumOps + 1
End If
Select Case NumOps
Case 0
If Operator(Index).Caption = "-" And LastInput <> "NEG" Then
Readout = "-" & Readout
LastInput = "NEG"
End If
Case 1
Op1 = Readout
If Operator(Index).Caption = "-" And LastInput <> "NUMS" And OpFlag <> "=" Then
Readout = "-"
LastInput = "NEG"
End If
Case 2
Op2 = TempReadout
Select Case OpFlag
Case "+"
Op1 = CDbl(Op1) + CDbl(Op2)
Case "-"
Op1 = CDbl(Op1) - CDbl(Op2)
Case "X"
Op1 = CDbl(Op1) * CDbl(Op2)
Case "/"
If Op2 = 0 Then
MsgBox "Can't divide by zero", 48, "Calculator"
Else
Op1 = CDbl(Op1) / CDbl(Op2)
End If
Case "="
Op1 = CDbl(Op2)
Case "%"
Op1 = CDbl(Op1) * CDbl(Op2)
End Select
Readout = Op1
NumOps = 1
End Select
If LastInput <> "NEG" Then
LastInput = "OPS"
OpFlag = Operator(Index).Caption
End If
End SubPrivate Sub Operator_KeyPress(Index As Integer, KeyAscii As Integer)
PressKey (KeyAscii)
End Sub' Click event procedure for percent key (%).
' Compute and display a percentage of the first operand.
Private Sub Percent_Click()
Readout = Readout / 100
LastInput = "Ops"
OpFlag = "%"
NumOps = NumOps + 1
DecimalFlag = True
End Sub
Private Sub Percent_KeyPress(KeyAscii As Integer)
Dim Char As String
Char = Chr(KeyAscii)
If Char = "%" Then
Readout = Readout / 100
LastInput = "Ops"
OpFlag = "%"
NumOps = NumOps + 1
DecimalFlag = True
End If
End Sub
Public Sub Plus()
CancelEntry.SetFocus
SendKeys "{+}", True
End Sub
Public Sub Subtract()
CancelEntry.SetFocus
SendKeys "{-}", True
End Sub
Public Sub Divide()
CancelEntry.SetFocus
SendKeys "/", True
End Sub
Public Sub Equals()
CancelEntry.SetFocus
SendKeys "{=}", True
End Sub
Public Sub MultiPly()
CancelEntry.SetFocus
SendKeys "*", True
End Sub
Public Sub SendValue(Number As Double)
CancelEntry.SetFocus
SendKeys Number, True
End Sub