Results 1 to 12 of 12

Thread: combobox1.text is not = "YES" or "NO" or "Maybe"

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2013
    Posts
    134

    combobox1.text is not = "YES" or "NO" or "Maybe"

    1234
    Last edited by KRENAR; Dec 5th, 2014 at 06:11 AM.

  2. #2
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,989

    Re: combobox1.text is not = "YES" or "NO" or "Maybe"

    I'd be inclined to look at SelectedIndex rather than the .Text. It would make for an easier comparison. How many different answers are you allowing the user to select from anyways? Yes, No, and Maybe seem to cover every situation.
    My usual boring signature: Nothing

  3. #3
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,579

    Re: combobox1.text is not = "YES" or "NO" or "Maybe"

    Code:
            If ComboBox1.Text <> "YES" AndAlso ComboBox1.Text <> "NO" AndAlso ComboBox1.Text <> "MAYBE" Then
                MessageBox.Show("Exit Sub")
            End If



  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Oct 2013
    Posts
    134

    Re: combobox1.text is not = "YES" or "NO" or "Maybe"

    1234
    Last edited by KRENAR; Dec 5th, 2014 at 06:11 AM.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Oct 2013
    Posts
    134

    Re: combobox1.text is not = "YES" or "NO" or "Maybe"

    1234
    Last edited by KRENAR; Dec 5th, 2014 at 06:11 AM.

  6. #6
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,196

    Re: combobox1.text is not = "YES" or "NO" or "Maybe"

    If you set the combobox DropDownStyle property to DropdownList, the user can't enter anything, they must select from the list.

  7. #7
    Fanatic Member Flashbond's Avatar
    Join Date
    Jan 2013
    Location
    Istanbul
    Posts
    646

    Re: combobox1.text is not = "YES" or "NO" or "Maybe"

    Quote Originally Posted by wes4dbt View Post
    If you set the combobox DropDownStyle property to DropdownList, the user can't enter anything, they must select from the list.
    Yeah, that's definately what should be in your case. Also set Text property of ComboBox to your first value to avoid empty input.
    God, are you punishing me because my hair is better than yours? -Jack Donaghy

  8. #8
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,467

    Re: combobox1.text is not = "YES" or "NO" or "Maybe"

    try this:

    Code:
    MsgBox(New String() {"YES", "NO", "Maybe"}.All(Function(s) ComboBox1.Text <> s))

  9. #9
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,196

    Re: combobox1.text is not = "YES" or "NO" or "Maybe"

    MsgBox(New String() {"YES", "NO", "Maybe"}.All(Function(s) ComboBox1.Text <> s))
    Don't mean to hijack this thread but I would like to know how this works. What is "s" and why are you using Msgbox instead of MessageBox

  10. #10
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,467

    Re: combobox1.text is not = "YES" or "NO" or "Maybe"

    Code:
    Dim a() As String = {"YES", "NO", "Maybe"}
    'a.All(Function(s) ComboBox1.Text <> s)
    'is equivalent to:
    
    For Each s As String In a
    
    Next

  11. #11
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    25,467

    Re: combobox1.text is not = "YES" or "NO" or "Maybe"

    Quote Originally Posted by wes4dbt View Post
    and why are you using Msgbox instead of MessageBox
    because it's shorter + I always have

  12. #12
    PowerPoster
    Join Date
    Sep 2005
    Location
    Modesto, Ca.
    Posts
    5,196

    Re: combobox1.text is not = "YES" or "NO" or "Maybe"

    .Paul, thanks
    Learn something new everyday.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width