如果在VB6.0中使用comboBox选择其他 [英] If Else with comboBox selection in VB6.0

查看:185
本文介绍了如果在VB6.0中使用comboBox选择其他的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果条件在VB6.0中



如何为下拉选项写下多个If条件,例如



我有一个下拉列表ddlState它包含5个状态,选项值为1,2,3,4,5



SO这个假设我选择了选项1,2然后打印以下消息,如果我选择3,4和5然后不同的东西得到打印



 < span class =code-keyword>如果 Instr(消息, ) =  1  2  

打印消息

elseIf Instr(消息, )= 3 4 5

打印另一条消息

Else
msg =
结束 如果



我该怎么写呢

解决方案

您还有两个答案显示如何更改if语句语法。我建议您查看Select ... case语句,这应该会简化您的逻辑。



可以找到Select语句的信息< a href =http://msdn.microsoft.com/en-us/library/cy37t14y%28v=vs.80%29.aspx>这里 [ ^ ]。


< blockquote>

 如果 Instr(消息, )=  1   Instr(消息, )=  2  

打印消息

elseIf Instr(消息, )= 3 Instr(消息, )= 4 < span class =code-keyword>或 Instr(消息, ) = 5

打印另一条消息

Else
msg =
结束 如果


如果您从这些中学习,那就更好..

http://www.vb6.us/tutorials/visual-basic-组合框教程 [ ^ ]

http://www.vb-helper.com/howto_select_item_from_item_data.html [ ^ ]


If condition in the VB6.0

How can i write multiple If condition for the dropdown selection for eg

I have a dropdownlist ddlState it contains 5 state with option values as 1 , 2 , 3 , 4 , 5

SO in this suppose i select the option 1 , 2 then the following message is print and if i select the 3 , 4 and 5 then something different gets print

If Instr(message , "%" ) = 1 , 2 
 (
   print message
 )
elseIf Instr (message , "%" ) =  3 , 4 , 5
 (
 print another message 
 )
 Else
  msg = ""
 End If


How can i write so

解决方案

You have two other answers that show how to change the 'if' statement syntax. I would suggest that you look at the "Select...case" statement, which should simplify your logic a bit.

Info on the Select statement can be found here[^].


If Instr(message , "%" ) = 1 Or Instr(message , "%" ) = 2
(
    print message
)
elseIf Instr (message , "%" ) = 3 Or Instr(message , "%" ) = 4 Or Instr(message , "%" ) = 5
(
    print another message
)
Else
    msg = ""
End If


Better if you learn form these..
http://www.vb6.us/tutorials/visual-basic-combo-box-tutorial[^]
http://www.vb-helper.com/howto_select_item_from_item_data.html[^]


这篇关于如果在VB6.0中使用comboBox选择其他的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆