vb编写选择题时发生莫名其妙的错误 请求各位高手帮忙
我是这样:三个A、B、C按钮,一个空白标签,点击A、B、C分别会使标签上显示A、B、C,共有五道题PrivateSubCommand1_Click()label1.Cap...
我是这样:三个A、B、C按钮,一个空白标签,点击A、B、C分别会使标签上显示A、B、C,共有五道题
Private Sub Command1_Click()
label1.Caption = "A"
End Sub
我按同样的方法编写,为什么到最后一道题点A、B、C就会发生错误“实时错误424,要求对象”,可是我写了对象啊?怎么回事啊?以下是全部代码:
Private Sub Command1_Click()
labela.Caption = "A"
End Sub
Private Sub Command10_Click()
Labelg.Caption = "A"
End Sub
Private Sub Command11_Click()
Labelg.Caption = "B"
End Sub
Private Sub Command12_Click()
Labelg.Caption = "C"
End Sub
Private Sub Command13_Click()
Labeldi.Caption = "A"
End Sub
Private Sub Command14_Click()
Labeldi.Caption = "B"
End Sub
Private Sub Command15_Click()
Labeldi.Caption = "C"
End Sub
Private Sub Command2_Click()
labela.Caption = "B"
End Sub
Private Sub Command3_Click()
labela.Caption = "C"
End Sub
Private Sub Command4_Click()
Labelc.Caption = "A"
End Sub
Private Sub Command5_Click()
Labelc.Caption = "B"
End Sub
Private Sub Command6_Click()
Labelc.Caption = "C"
End Sub
Private Sub Command7_Click()
Labele.Caption = "A"
End Sub
Private Sub Command8_Click()
Labele.Caption = "B"
End Sub
Private Sub Command9_Click()
Labele.Caption = "C"
End Sub
各位高手帮帮忙! 展开
Private Sub Command1_Click()
label1.Caption = "A"
End Sub
我按同样的方法编写,为什么到最后一道题点A、B、C就会发生错误“实时错误424,要求对象”,可是我写了对象啊?怎么回事啊?以下是全部代码:
Private Sub Command1_Click()
labela.Caption = "A"
End Sub
Private Sub Command10_Click()
Labelg.Caption = "A"
End Sub
Private Sub Command11_Click()
Labelg.Caption = "B"
End Sub
Private Sub Command12_Click()
Labelg.Caption = "C"
End Sub
Private Sub Command13_Click()
Labeldi.Caption = "A"
End Sub
Private Sub Command14_Click()
Labeldi.Caption = "B"
End Sub
Private Sub Command15_Click()
Labeldi.Caption = "C"
End Sub
Private Sub Command2_Click()
labela.Caption = "B"
End Sub
Private Sub Command3_Click()
labela.Caption = "C"
End Sub
Private Sub Command4_Click()
Labelc.Caption = "A"
End Sub
Private Sub Command5_Click()
Labelc.Caption = "B"
End Sub
Private Sub Command6_Click()
Labelc.Caption = "C"
End Sub
Private Sub Command7_Click()
Labele.Caption = "A"
End Sub
Private Sub Command8_Click()
Labele.Caption = "B"
End Sub
Private Sub Command9_Click()
Labele.Caption = "C"
End Sub
各位高手帮帮忙! 展开
3个回答
展开全部
你重新建个项目,拉进去三个A、B、C按钮,一个空白标签;
输入代码的时候,把原来的代码全部清空,输入下面的代码运行就能看到效果了。
然后在自己参悟下,相信你会弄明白的。
Option Explicit
Private Sub Command1_Click()
Labeld1.Caption = "A"
End Sub
Private Sub Command2_Click()
Labeld1.Caption = "B"
End Sub
Private Sub Command3_Click()
Labeld1.Caption = "C"
End Sub
输入代码的时候,把原来的代码全部清空,输入下面的代码运行就能看到效果了。
然后在自己参悟下,相信你会弄明白的。
Option Explicit
Private Sub Command1_Click()
Labeld1.Caption = "A"
End Sub
Private Sub Command2_Click()
Labeld1.Caption = "B"
End Sub
Private Sub Command3_Click()
Labeld1.Caption = "C"
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
变量名错了,你只有一个标签,也就是label1,而后面你却用了labela,labelc,labelc.....系统找不到相应对象的,把全部labelX都改成label1就好了。例如:Private Sub Command1_Click()
labela.Caption = "A"
End Sub
这一段,把labela.caption="A"改成label1.caption="A"。下面的全改完就好了。
不知道有没有理解错误,希望对你有帮助~
labela.Caption = "A"
End Sub
这一段,把labela.caption="A"改成label1.caption="A"。下面的全改完就好了。
不知道有没有理解错误,希望对你有帮助~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询