完全是送分的问题,是关于"或"的判断

TreelightLSH 2004-05-06 10:42:43
例如判断Text1.Text="a"或"b"或'c"
如何写?各位不要见笑哦,小弟初学
...全文
104 25 打赏 收藏 转发到动态 举报
写回复
用AI写文章
25 条回复
切换为时间正序
请发表友善的回复…
发表回复
silverblade 2004-05-06
  • 打赏
  • 举报
回复
用LIKE运算符最方便,但不保证性能
if text1.text like [abc] then
shortppsy 2004-05-06
  • 打赏
  • 举报
回复
晕,不好意思,我看错了
online 2004-05-06
  • 打赏
  • 举报
回复
Private Sub Command2_Click()
If Combo1.Text = "单价" Or Combo1.Text = "实际购价" Then
MsgBox ("good")
End If
End Sub
射天狼 2004-05-06
  • 打赏
  • 举报
回复
我晕`~~~~~``
shortppsy 2004-05-06
  • 打赏
  • 举报
回复
dim temp as string
temp=str(combo1l.text)
If Combo1.Text = "单价" Or "实际购价" Then
MsgBox ("good")
End If

TreelightLSH 2004-05-06
  • 打赏
  • 举报
回复
我的程序如下:
If Combo1.Text = "单价" Or "实际购价" Then
MsgBox ("good")
End If
会提示"类型不匹配"
如何解决?
hackate 2004-05-06
  • 打赏
  • 举报
回复
哈哈,可能很多人开始都写成

if text1.text="a" or "b" or "c"

这样是不行的,呵呵,偶那时候就笨得这样啊,搞了半天,一想,好像不能这样啊,哈哈,

楼上大狭们的方法就对了都
haipingma 2004-05-06
  • 打赏
  • 举报
回复
用or就可以了
Mi_Bo 2004-05-06
  • 打赏
  • 举报
回复
If text1.text="a" or text1.text="b" or text1.text="c" then ……
tztz520 2004-05-06
  • 打赏
  • 举报
回复
不好意思,按错键发了出去.

If Switch(Text1.Text = "a", 1, Text1.Text = "b", 1, Text1.Text = "c", 1, 1 = 1, 0) = 1 Then
MsgBox "通过"
Else
MsgBox "不能通过"
End If
Wenking003 2004-05-06
  • 打赏
  • 举报
回复
使用逻辑操作符 Or
tztz520 2004-05-06
  • 打赏
  • 举报
回复
可能有很多种方法,楼上的比
chinaren502 2004-05-06
  • 打赏
  • 举报
回复
Private Sub Command1_Click()
If Text1.Text = "a" Or Text1.Text = "b" Or Text1.Text = "c" Then
.......
Else
.........
End If

End Sub
pigpag 2004-05-06
  • 打赏
  • 举报
回复
原来已经写过了……

这是个提升代码可读性的方案,推荐
shortppsy 2004-05-06
  • 打赏
  • 举报
回复
or
pigpag 2004-05-06
  • 打赏
  • 举报
回复
Select Case Text1.Text
Case "a", "b", "c"
' 是
...
End Select
online 2004-05-06
  • 打赏
  • 举报
回复
Option Explicit

Private Sub Command1_Click()
If Text1.Text = "a" Or Text1.Text = "b" Or Text1.Text = "c" Then
MsgBox "通过"
Else
MsgBox "没有"
End If

End Sub
d1ll 2004-05-06
  • 打赏
  • 举报
回复
观摩中。。。。。

羡慕中。。。。

^^
986753421 2004-05-06
  • 打赏
  • 举报
回复
好像还没人写下面的方法:
select case text1.text
case "a","b","c"
msgbox "呵呵"
end select
northwolves 2004-05-06
  • 打赏
  • 举报
回复
呵呵,

Private Sub Command1_Click()
MsgBox UBound(Filter(Array("a", "b", "c"), Text1.Text)) = "-1" '不包含
End Sub
加载更多回复(5)

7,763

社区成员

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

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