我自己写的第一个vb程序(原程序)请大家指点指点!帮我看看,有什么错的,对的?
form1.Visual Basic Form File文件
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "计算器"
ClientHeight = 3480
ClientLeft = 5070
ClientTop = 2085
ClientWidth = 3960
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3480
ScaleWidth = 3960
Begin VB.CommandButton cmd
Caption = "="
Height = 375
Left = 3120
TabIndex = 22
Top = 600
Width = 495
End
Begin VB.CommandButton CmdC
Caption = "C"
Height = 375
Left = 2280
TabIndex = 21
Top = 600
Width = 495
End
Begin VB.CommandButton cmdCE
Caption = "CE"
Height = 375
Left = 1440
TabIndex = 20
Top = 600
Width = 495
End
Begin VB.CommandButton Command2
Caption = "Backspace"
Height = 375
Left = 240
TabIndex = 19
Top = 600
Width = 975
End
Begin VB.TextBox Text1
Alignment = 1 'Right Justify
Height = 285
Left = 240
TabIndex = 0
Top = 120
Width = 3375
End
Begin VB.Frame Frame2
Height = 2175
Left = 2520
TabIndex = 12
Top = 1080
Width = 1215
Begin VB.CommandButton Command3
Caption = "/"
Height = 375
Index = 4
Left = 120
TabIndex = 16
Top = 1680
Width = 975
End
Begin VB.CommandButton Command3
Caption = "*"
Height = 375
Index = 3
Left = 120
TabIndex = 15
Top = 1200
Width = 975
End
Begin VB.CommandButton Command3
Caption = "-"
Height = 375
Index = 2
Left = 120
TabIndex = 14
Top = 720
Width = 975
End
Begin VB.CommandButton Command3
Caption = "+"
Height = 375
Index = 1
Left = 120
TabIndex = 13
Top = 240
Width = 975
End
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 375
Index = 9
Left = 1800
TabIndex = 11
Top = 2280
Width = 495
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 375
Index = 8
Left = 1080
TabIndex = 10
Top = 2280
Width = 495
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 375
Index = 7
Left = 360
TabIndex = 9
Top = 2280
Width = 495
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 375
Index = 6
Left = 1800
TabIndex = 8
Top = 1800
Width = 495
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 375
Index = 5
Left = 1080
TabIndex = 7
Top = 1800
Width = 495
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 375
Index = 4
Left = 360
TabIndex = 6
Top = 1800
Width = 495
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 375
Index = 3
Left = 1800
TabIndex = 5
Top = 1320
Width = 495
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 375
Index = 2
Left = 1080
TabIndex = 4
Top = 1320
Width = 495
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 375
Index = 1
Left = 360
TabIndex = 3
Top = 1320
Width = 495
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 375
Index = 0
Left = 360
TabIndex = 2
Top = 2760
Width = 495
End
Begin VB.Frame Frame1
Height = 2175
Left = 240
TabIndex = 1
Top = 1080
Width = 2175
Begin VB.CommandButton Command1
Caption = "."
Height = 375
Index = 11
Left = 1560
TabIndex = 18
Top = 1680
Width = 495
End
Begin VB.CommandButton Command1
Caption = "+/-"
Height = 375
Index = 10
Left = 840
MaskColor = &H80000000&
TabIndex = 17
Top = 1680
Width = 495
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim i As Integer
Dim var1, var2 As Double
Dim flag As String
Dim addindex As Integer
Dim jieguo As Variant
Dim fuhao1 As Integer
Private Sub cmd_Click()
yunsuan
Text1.Text = jieguo
var1 = jieguo
End Sub
Private Sub Command1_Click(index As Integer)
Select Case index
Case 0
addindex = index
fuhao
Case 1
addindex = index
fuhao
Case 2
addindex = index
fuhao
Case 3
addindex = index
fuhao
Case 4
addindex = index
fuhao
Case 5
addindex = index
fuhao
Case 6
addindex = index
fuhao
Case 7
addindex = index
fuhao
Case 8
addindex = index
fuhao
Case 9
addindex = index
fuhao
Case 10
zengfuhao
Case 11
If fuhao1 = 1 Then
var2 = Val(Text1.Text)
xiaoshudian2
Else
var1 = Val(Text1.Text)
xiaoshudian1
End If
End Select
End Sub
Private Sub Command3_Click(index As Integer)
var1 = Val(Text1.Text)
Select Case index
Case 1
flag = "+"
yunsuan1
Case 2
flag = "-"
yunsuan1
Case 3
flag = "*"
yunsuan1
Case 4
flag = "/"
yunsuan1
End Select
End Sub
Private Sub Cmdce_Click()
var1 = Val(Text1.Text)
var2 = 0
Text1.Text = 0
End Sub
Private Sub Cmdc_Click()
var1 = 0
var2 = 0
Text1.Text = 0
flag = 0
i = 0
jieguo = 0
fuhao1 = 0
End Sub
Private Sub Form_Load()
Text1.Text = 0
i = 0
For i = 0 To 9
Command1(i).Caption = i
Next
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode >= 48 And KeyCode <= 57 Or KeyCode = 8 Or KeyCode = 46 Then
Text1.Locked = False
Else
Text1.Locked = True
End If
End Sub
Sub fuhao()
If fuhao1 = 0 Then '判断是否点击运算符号
If flag <> "" Then
Text1.Text = 0 '如果点击运算符号文本框清0
fuhao1 = 1 '符值fuhao为是
End If
End If
If fuhao1 = 1 Then
add2
Else
add1
End If
End Sub
Sub add1()
If var1 = 0 Then
Text1.Text = addindex
var1 = Val(Text1.Text)
Else
Text1.Text = Text1.Text & addindex
End If
End Sub
Sub add2()
If var2 = 0 Then
Text1.Text = addindex
var2 = Val(Text1.Text)
Else
Text1.Text = Text1.Text & addindex
End If
End Sub
Sub yunsuan()
Select Case flag '判断运算符进行加减乘除运算
Case "+"
jieguo = var1 + var2
Case "-"
jieguo = var1 - var2
Case "*"
jieguo = var1 * var2
Case "/"
jieguo = var1 / var2
End Select
var2 = 0
End Sub
Sub yunsuan1()
If var2 <> 0 Then
yunsuan
Text1.Text = jieguo
var1 = Val(jieguo)
End If
End Sub
Function zengfuhao()
If Text1.Text > 0 Then
Text1.Text = -Val(Text1.Text)
Else
Text1.Text = -Val(Text1.Text)
End If
End Function
Sub xiaoshudian1()
Dim x, y As String
x = "."
y = Str$(var1)
If InStrRev(x, var1) <> x Then
var1 = var1 & x
Text1.Text = var1
End If
End Sub
Sub xiaoshudian2()
Dim x, y As String
x = "."
y = Str$(var2)
If InStrRev(x, var2) <> x Then
var2 = var2 & x
Text1.Text = var2
End If
End Sub
帮我看看,有什么错的,对的?