[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.
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
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 ""?
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
Re: [RESOLVED] how do i compare only the characters in a combo box's text?
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
....:wave:
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!