请教问题?

cxm3570222 2003-08-24 11:48:55
为什么我编的程序在CHSCK控件在同时打勾时文本框无法显示"我爱音乐和体育"呢?而只能显示我爱音乐或我爱体育?
Private Sub Check1_Click(Index As Integer)
If Index = 0 Then
Text2.Text = "我爱音乐"
ElseIf Index = 1 Then
Text2.Text = "我爱体育"
ElseIf Index = 0 And Index = 1 Then
Text2.Text = "我爱音乐体育"
End If
End Sub

Private Sub Option1_Click()
If Option1.Value Then
Text1.Text = "我是男生"
End If
End Sub

Private Sub Option2_Click()
If Option2.Value Then
Text1.Text = "我是女生"
End If
End Sub
...全文
108 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
rainstormmaster 2003-08-25
  • 打赏
  • 举报
回复
回复人: horsewww(黑马) ( ) 信誉:100 2003-08-25 00:09:00 得分:0

回复人: rainstormmaster(rainstormmaster) ( ) 信誉:115 2003-08-25 00:09:00 得分:0

呵呵,回复时间相同,有意思
rainstormmaster 2003-08-25
  • 打赏
  • 举报
回复
逻辑错误,这句ElseIf Index = 0 And Index = 1 Then
有问题,原因是:你不能同时去点击两个checkbox,修正一下:



Option Explicit

Private Sub Check1_Click(Index As Integer)
If Check1(0).Value = 1 And Check1(1).Value = 0 Then
Text2.Text = "我爱音乐"
ElseIf Check1(0).Value = 0 And Check1(1).Value = 1 Then
Text2.Text = "我爱体育"
ElseIf Check1(0).Value = 1 And Check1(1).Value = 1 Then
Text2.Text = "我爱音乐体育"
Else
Text2.Text = "我不爱音乐和体育"
End If

End Sub

Private Sub Option1_Click()
If Option1.Value Then
Text1.Text = "我是男生"
End If
End Sub

Private Sub Option2_Click()
If Option2.Value Then
Text1.Text = "我是女生"
End If
End Sub

horsewww 2003-08-25
  • 打赏
  • 举报
回复
If Index = 0 Then
Text2.Text = "我爱音乐" 'index=0 时执行
ElseIf Index = 1 Then
Text2.Text = "我爱体育" 'index=1 时执行
ElseIf Index = 0 And Index = 1 Then
Text2.Text = "我爱音乐体育" '永远不执行 Index怎么可以即等于0又等于1呢
End If

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧