VB 控件数组问题.
来源:百度知道 编辑:UC知道 时间:2024/05/08 07:50:44
Private Sub Command1_Click()
If Check1(0).Value = 1 Then
a = a + Val(Label2(0).Caption) + Text1(0).Text
If Check1(1).Value = 1 Then
a = a + Val(Label2(1).Caption) + Text1(1).Text
If Check1(2).Value = 1 Then
a = a + Val(Label2(2).Caption) + Text1(2).Text
Else
Text2.Text = a
End Sub
这段代码有问题吗?为什么点下command1后提示 "块IF 没有end if"
程序的截图我发到FTP里了
http://www.zhouyanbo.com/vb.jpg
请高手说明,不胜感激.
If Check1(0).Value = 1 Then
a = a + Val(Label2(0).Caption) + Text1(0).Text
If Check1(1).Value = 1 Then
a = a + Val(Label2(1).Caption) + Text1(1).Text
If Check1(2).Value = 1 Then
a = a + Val(Label2(2).Caption) + Text1(2).Text
Else
Text2.Text = a
End Sub
这段代码有问题吗?为什么点下command1后提示 "块IF 没有end if"
程序的截图我发到FTP里了
http://www.zhouyanbo.com/vb.jpg
请高手说明,不胜感激.
你的代码没有问题,只是你忘记加上end if
在Text2.Text = a
后面加上end if
最好在
a = a + Val(Label2(0).Caption) + Text1(0).Text
和a = a + Val(Label2(1).Caption) + Text1(1).Text
后面也加上end if
少end if ,你可以这样写
If Check1(0).Value = 1 Then
a = a + Val(Label2(0).Caption) + Text1(0).Text
If Check1(1).Value = 1 Then
a = a + Val(Label2(1).Caption) + Text1(1).Text
If Check1(2).Value = 1 Then
a = a + Val(Label2(2).Caption) + Text1(2).Text
end if
Else
Text2.Text = a
end if