我有大约5个隐藏文本框和1个按钮,当我点击它时它会逐个显示隐藏文本,但我想要做的是当我单击按钮一次只出现1个文本框然后会出现一个消息框说"你想继续"是还是不是?如果我按是,则会出现第二个文本框,但是当我按否时,应该关闭消息框。
我在按钮上有这个代码:
Private Sub revealtxtbox_Click(ByVal senders As System.Object, ByVal e As System.EventArgs) Handles revealtxtbox.Click
txtbox1.visible = True
If MsgBox("Do you Want to Continue", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Sample System") = MsgBoxResult.Yes then
txtbox2.visible = true
Elseif MsgBoxResult.Yes then
txtbox3.visible = true
Elseif MsgBoxResult.Yes then
txtbox4.visible = true
Elseif MsgBoxResult.Yes then
txtbox5.visible = true
End if
上面的代码有点工作但是当我按NO,txtbox3显示并且msgbox关闭时,它不应该显示txtbox3,它应该只关闭msgbox。
答案 0 :(得分:-1)
尝试更像这样的东西:
Private Sub revealtxtbox_Click(ByVal senders As System.Object, ByVal e As System.EventArgs) Handles revealtxtbox.Click
txtbox1.visible = True
If MsgBox("Do you Want to Continue", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Sample System") <> MsgBoxResult.Yes then
Exit Sub
End If
txtbox2.visible = true
If MsgBox("Do you Want to Continue", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Sample System") <> MsgBoxResult.Yes then
Exit Sub
End If
txtbox3.visible = true
If MsgBox("Do you Want to Continue", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Sample System") <> MsgBoxResult.Yes then
Exit Sub
End If
txtbox4.visible = true
If MsgBox("Do you Want to Continue", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Sample System") <> MsgBoxResult.Yes then
Exit Sub
End If
txtbox5.visible = true
End if