vb的复选框 选择题程序 怎么设计下面的程序

来源:百度知道 编辑:UC知道 时间:2024/05/20 05:19:29
Private Sub Command1_Click()

If Check1.Value = 1 Then Text1 = 5
If Check6.Value = 1 Then Text2 = 5
If Check11.Value = 1 Then Text3 = 5
If Check15.Value = 1 Then Text5 = 5
If Check18.Value = 1 Then Text6 = 5
If Check23.Value = 1 Then Text7 = 5
If Check25.Value = 1 Then Text8 = 5
If Check30.Value = 1 Then Text9 = 5
If Check35.Value = 1 Then Text10 = 5
If Check38.Value = 1 Then Text11 = 5
Text4 = Val(Text1) + Val(Text2) + Val(Text3) + Val(Text5) + Val(Text6) + Val(Text7) + Val(Text8) + Val(Text9) + Val(Text10) + Val(Text11)

End Sub

Private Sub Command2_Click()
Check1.Value = 0
Check2.Value = 0
Check3.Value = 0
Check4.Value = 0
Check5.Value = 0
Check6.Value = 0

Check7.Value = 0
Check8.Value = 0
Check9.Value = 0
Check10.Value = 0
Check11.Value = 0
Check12.Value = 0

Check13.Value = 0
Check14.Value = 0
Check15.Value = 0

要么得在If Check1.Value = 1 Then Text1 = 5
后面加上else Text1 = 0 其它类同
要么把Text4=""
改为Text1="" .......Text11=""
要全为清空

因为会出现数据不清空的原因来自这一句
Text4 = Val(Text1) + Val(Text2) + Val(Text3) + Val(Text5) + Val(Text6) + Val(Text7) + Val(Text8) + Val(Text9) + Val(Text10) + Val(Text11)

另外,强烈建议用控件数组来
用For清空

你这么多的控件建议你用一个控件数组来.

我也才刚刚开始学

不过你清空的时候应该把text1到text11也全清空吧