|
-
Jul 8th, 2010, 06:24 PM
#1
Thread Starter
Fanatic Member
[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.
-
Jul 8th, 2010, 06:44 PM
#2
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
-
Jul 8th, 2010, 07:06 PM
#3
Thread Starter
Fanatic Member
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 ""?
-
Jul 8th, 2010, 07:44 PM
#4
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
-
Jul 8th, 2010, 07:55 PM
#5
Thread Starter
Fanatic Member
Re: [RESOLVED] how do i compare only the characters in a combo box's text?
-
Jul 9th, 2010, 11:33 AM
#6
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,...
-
Jul 9th, 2010, 12:41 PM
#7
Thread Starter
Fanatic Member
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!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|