例如判断Text1.Text="a"或"b"或'c"
如何写?各位不要见笑哦,小弟初学

解决方案 »

  1.   

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

  2.   

    Private Sub Command1_Click()
    If Text1.Text = "a" Or Text1.Text = "b" Or Text1.Text = "c" Then
    .......
    Else
    .........
    End IfEnd Sub
      

  3.   

    不好意思,按错键发了出去.If Switch(Text1.Text = "a", 1, Text1.Text = "b", 1, Text1.Text = "c", 1, 1 = 1, 0) = 1 Then
        MsgBox "通过"
    Else
        MsgBox "不能通过"
    End If
      

  4.   

    哈哈,可能很多人开始都写成if text1.text="a" or "b" or "c"这样是不行的,呵呵,偶那时候就笨得这样啊,搞了半天,一想,好像不能这样啊,哈哈,楼上大狭们的方法就对了都
      

  5.   

    我的程序如下:
    If Combo1.Text = "单价" Or "实际购价" Then
      MsgBox ("good")
      End If
    会提示"类型不匹配"
    如何解决?
      

  6.   

    dim temp as string
    temp=str(combo1l.text)
    If Combo1.Text = "单价" Or "实际购价" Then
      MsgBox ("good")
      End If
      

  7.   

    Private Sub Command2_Click()
    If Combo1.Text = "单价" Or Combo1.Text = "实际购价" Then
      MsgBox ("good")
      End If
    End Sub
      

  8.   

    用LIKE运算符最方便,但不保证性能
    if text1.text like [abc] then
      

  9.   

    如果是判断严格等于a、b、c这种连续编码的字符。tOutBool=Asc(Text1.Text)>96 or Asc(Text1.Text)<100如果是判断Text1.Text等于一系列字符,如果特别多的话(比如不止a、b、c三个,而是一万多个比较)Dim A() As String
    Dim I As Long<设定数组A()的值,比如:A()=Split("a,b,c",",")>For I=1 To Ubound(A)
      tOutNum=(Text1.Text=A(I) And I)
      tOutBool=CBool(tOutNum)
      If tOutBool Then Exit For
    NexttOutNum字符串的数组编号。如果Text1.text=B则返回2
    tOutBool是Text1.text是否等于其中一个的布尔值。
      

  10.   

    还有一个更简单的办法(这可能是最有性格的一个算法了):If CBool(Len(Text1.Text)) Then
      tOutBool=CBool(Instr("a,b,c,",Text1.Text & ","))
    End If
      

  11.   

    差点忘记了!上面的代码可以写成:tOutBool=CBool(Len(Text1.Text)) And CBool(Instr("a,b,c,",Text1.Text & ","))这是最简单的形式。
      

  12.   

    呵呵,Private Sub Command1_Click()
    MsgBox UBound(Filter(Array("a", "b", "c"), Text1.Text)) = "-1" '不包含
    End Sub
      

  13.   

    好像还没人写下面的方法:
    select case text1.text
    case "a","b","c"
    msgbox "呵呵"
    end select
      

  14.   

    Select Case Text1.Text
    Case "a", "b", "c"
       ' 是
       ...
    End Select
      

  15.   

    If text1.text="a" or text1.text="b" or text1.text="c" then ……