Results 1 to 7 of 7

Thread: [RESOLVED] how do i compare only the characters in a combo box's text?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Resolved [RESOLVED] how do i compare only the characters in a combo box's text?

    I would think the Trim, right? It would be possible to compare the characters(letters and #s) in a combo box's text, right? It is going to have "" text by default. so............... Yeah.
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: how do i compare only the characters in a combo box's text?

    Huh? that didn't make sense... compare what to what? And what does "Trim" have to do with it (which only strips leading and trailing white space characters from a string)....

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Re: how do i compare only the characters in a combo box's text?

    Okay. I want to compare lets say.... combo1.text <> combo2.text. however, i dont want it to count if combo2.text = "" and combo1.text = "" i have like 12 comboboxes. I was thinking if i did If Trim(combo1.text), would it not count it as ""?
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: [RESOLVED] how do i compare only the characters in a combo box's text?

    As I said... Trim removes leading and trailing spaces from a string....
    Trim("ABC ") = "ABC"
    Trim(" ABC ") = "ABC"
    Trim(" ") = ""
    Trim("") = ""

    so... no, that won't work... since your comboboxes will be "" already... what you need is something like this:

    Code:
    If comboBox1.Text <> "" And Combobox1.Text = ComboBox2.Text.....
    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Re: [RESOLVED] how do i compare only the characters in a combo box's text?

    Okay. Thanks. =D
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

  6. #6
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: [RESOLVED] how do i compare only the characters in a combo box's text?

    If you set the ComboBoxes Style property to DropdownList, you don't need to worry about empty string. Because, it wouldn't allow users to enter anything into the combobox. Users can only select an item from the dropdown list.

    Example:
    Code:
    '// Set the STYLE property of ComboBox to DROPDOWNLIST
    Option Explicit
    
    Private Sub Command1_Click()
        If Combo1.ListIndex = -1 Then       '~~~ if user doesn't selected an item (blank item)
            MsgBox "Please select an item"
        Else
            '~~~ do the comparing here
            MsgBox Combo1.Text
        End If
    End Sub
    
    Private Sub Form_Load()
        '~~~ Sample data
        Combo1.AddItem "a"
        Combo1.AddItem "b"
        Combo1.AddItem "c"
    End Sub
    ....

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Re: [RESOLVED] how do i compare only the characters in a combo box's text?

    Yeah. Ik. I was just wondering, because when the form loads, the combobox is always blank. like it has items in its dropdown menu, but it starts "". xD I already fixed it. thanks everyone!
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

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