VERSION 5.00
Begin VB.Form Form1
ClientHeight = 3090
ClientLeft = 60
ClientTop = 450
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3090
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame1
Height = 2775
Left = 120
TabIndex = 0
Top = 120
Width = 4455
Begin VB.CommandButton Command1
Caption = "计算总价"
Height = 375
Left = 3120
TabIndex = 7
Top = 1920
Width = 1095
End
Begin VB.TextBox txt1
Height = 375
Left = 1320
TabIndex = 6
Text = "0"
Top = 1920
Width = 1575
End
Begin VB.OptionButton Option3
Caption = "97号汽油"
Height = 255
Left = 240
TabIndex = 3
Top = 1320
Width = 1215
End
Begin VB.OptionButton Option2
Caption = "93号汽油"
Height = 255
Left = 240
TabIndex = 2
Top = 840
Width = 1095
End
Begin VB.OptionButton Option1
Caption = "90号汽油"
Height = 255
Left = 240
TabIndex = 1
Top = 360
Value = -1 'True
Width = 1215
End
Begin VB.Label tb2
Caption = "2.8"
Height = 255
Left = 3000
TabIndex = 11
Top = 840
Width = 1215
End
Begin VB.Label tb3
Caption = "0"
Height = 375
Left = 3000
TabIndex = 10
Top = 1200
Width = 1335
End
Begin VB.Label Label1
Caption = "总价"
Height = 375
Left = 1680
TabIndex = 9
Top = 1320
Width = 975
End
Begin VB.Label Label6
Caption = "数量(升)"
Height = 375
Left = 360
TabIndex = 8
Top = 1920
Width = 975
End
Begin VB.Label Label5
Caption = "单价"
Height = 255
Left = 1680
TabIndex = 5
Top = 840
Width = 975
End
Begin VB.Label Label3
Caption = "数量(升)"
Height = 255
Left = 1560
TabIndex = 4
Top = 360
Width = 1335
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim l As Double
l = Val(txt1.Text)
If Option1.Value = True Then tb3.Caption = l * 2.8
If Option2.Value = True Then tb3.Caption = l * 3.4
If Option3.Value = True Then tb3.Caption = l * 3.6
End Sub
Private Sub Option1_Click()
tb2.Caption = "2.8元/升"
End Sub
Private Sub Option2_Click()
tb2.Caption = "3.4元/升"
End Sub
Private Sub Option3_Click()
tb2.Caption = "3.6元/升"
End Sub
给个邮箱,我把整个工程发给你
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command1
Caption = "Caculate"
Height = 375
Left = 2040
TabIndex = 7
Top = 2400
Width = 975
End
Begin VB.TextBox Text3
Height = 495
Left = 2400
TabIndex = 6
Top = 1800
Width = 855
End
Begin VB.TextBox Text2
Height = 495
Left = 2400
TabIndex = 5
Top = 1080
Width = 855
End
Begin VB.TextBox Text1
Height = 495
Left = 2400
TabIndex = 4
Top = 360
Width = 855
End
Begin VB.Frame Frame1
Caption = "Frame1"
Height = 2535
Left = 120
TabIndex = 0
Top = 240
Width = 1215
Begin VB.OptionButton Option3
Caption = "97#"
Height = 495
Left = 240
TabIndex = 3
Top = 1800
Width = 735
End
Begin VB.OptionButton Option2
Caption = "93#"
Height = 495
Left = 240
TabIndex = 2
Top = 1080
Width = 735
End
Begin VB.OptionButton Option1
Caption = "90#"
Height = 495
Left = 240
TabIndex = 1
Top = 360
Width = 735
End
End
Begin VB.Label Label3
Caption = "Total"
Height = 495
Left = 1440
TabIndex = 10
Top = 1920
Width = 735
End
Begin VB.Label Label2
Caption = "Litre"
Height = 615
Left = 1440
TabIndex = 9
Top = 360
Width = 735
End
Begin VB.Label Label1
Caption = "Price"
Height = 375
Left = 1440
TabIndex = 8
Top = 1200
Width = 735
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Price As Double
Private Sub Command1_Click()
Text3.Text = Val(Text1.Text) * Price
End Sub
Private Sub Option1_Click()
Text2.Text = "2.80"
Price = 2.8
End Sub
Private Sub Option2_Click()
Text2.Text = "3.40"
Price = 3.4
End Sub
Private Sub Option3_Click()
Text2.Text = "3.60"
Price = 3.6
End Sub
Private Sub Command1_Click()
Text3.Text = Text2.Text * Text1.Text
End Sub
Private Sub Op1_Click()
Text2.Text = 2.8
End Sub
Private Sub Op2_Click()
Text2.Text = 3.4
End Sub
Private Sub Op3_Click()
Text2.Text = 3.6
End Sub