主题:有关RadioButton1和checkbox的问题
luo1353167
[专家分:0] 发布于 2008-09-24 10:05:00
[size=3] 本人是新手又发新帖了,通过这个论坛我学到了不少,在此谢谢你们!!!
设计1个简单的购物系统。共有6种商品可供用户选择。用户可以选择其中的一种或几种。同时有4种付款方式供用户选择(电汇、邮汇、转帐、信用卡)用户必须选择一种且只能选择一种付款方式。在按下提交按钮后检查用户的选择。如果正确,给出致谢信息框同时总结用户的选择。
我不知道如何返回最后的结果,就是在致谢框同时总结用户的选择。本人是新手所有请详细点 最好是主要的代码。[em1][/size]
回复列表 (共2个回复)
沙发
老大徒伤悲 [专家分:29120] 发布于 2008-09-24 12:19:00
下面是Form1.frm文件的内容。你的主要功能已经在里面,缺少价格、金额和商品数量。
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 2940
ClientLeft = 60
ClientTop = 600
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 2940
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CheckBox Check1
Caption = "Check1"
Height = 495
Index = 5
Left = 0
TabIndex = 10
Top = 0
Width = 1215
End
Begin VB.CheckBox Check1
Caption = "Check1"
Height = 495
Index = 4
Left = 0
TabIndex = 9
Top = 0
Width = 1215
End
Begin VB.CheckBox Check1
Caption = "Check1"
Height = 495
Index = 3
Left = 0
TabIndex = 8
Top = 0
Width = 1215
End
Begin VB.CheckBox Check1
Caption = "Check1"
Height = 495
Index = 2
Left = 0
TabIndex = 7
Top = 0
Width = 1215
End
Begin VB.CheckBox Check1
Caption = "Check1"
Height = 495
Index = 1
Left = 0
TabIndex = 6
Top = 0
Width = 1215
End
Begin VB.CheckBox Check1
Caption = "Check1"
Height = 495
Index = 0
Left = 1800
TabIndex = 5
Top = 1200
Width = 1215
End
Begin VB.OptionButton Option1
Caption = "Option1"
Height = 495
Index = 3
Left = 0
TabIndex = 4
Top = 0
Width = 1215
End
[待续……
板凳
老大徒伤悲 [专家分:29120] 发布于 2008-09-24 12:19:00
……续]
Begin VB.OptionButton Option1
Caption = "Option1"
Height = 495
Index = 2
Left = 0
TabIndex = 3
Top = 0
Width = 1215
End
Begin VB.OptionButton Option1
Caption = "Option1"
Height = 495
Index = 1
Left = 0
TabIndex = 2
Top = 0
Width = 1215
End
Begin VB.OptionButton Option1
Caption = "Option1"
Height = 495
Index = 0
Left = 1800
TabIndex = 1
Top = 1200
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 495
Left = 2760
TabIndex = 0
Top = 2280
Width = 1215
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Const 付款方式 = "电汇、邮汇、转帐、信用卡"
Dim 付款 As Integer, a
Private Sub Command1_Click()
If 付款 = 0 Then
MsgBox "你还没有选定付款方式呢"
Exit Sub
End If
s = ""
For i = 0 To 5
If Check1(i) Then s = s & Check1(i).Caption & vbCrLf
Next i
If s <> "" Then
s = s & "选用" & a(付款) & "方式付款"
Else
s = "没有选购商品"
End If
MsgBox s
End Sub
Private Sub Form_Load()
Width = 7000
Height = 2800
For i = 0 To 5
Check1(i).Caption = "商品" & i + 1
Check1(i).Move 200 + 1000 * i, 200, 900, 400
Next i
a = Split(付款方式, "、")
For i = 0 To 3
Option1(i).Caption = a(i)
Option1(i).Move 200 + 1500 * i, 700, 1400, 400
Next i
Command1.Caption = "确定"
Command1.Move 5000, 1400, 1000, 400
End Sub
Private Sub Option1_Click(Index As Integer)
付款 = Index
End Sub
我来回复