.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old November 17th, 2004, 02:54 PM
gencor45 gencor45 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 4 gencor45 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Vb.net string question?

Im trying to compare a string from a textbox to string in a combo list box
and display the strings that compare in a messagebox.

My problem is that the textbox string will only compare to the text in the combo
box that matches exactly. For example, type in college i want that to compare to
fashion college in the combo box list and then display. I can only get it to match if
I type in fashion college, which isnt what I want to do.
Here is my code:
Dim loopIndexInteger As Integer

Dim maximumInteger As Integer

maximumInteger = listComboBox.Items.Count - 1

Dim listCompareString As String

Dim textCompareString As String

Dim matchString As String = ""

If inputTextBox.Text = "" Then

MessageBox.Show("You must enter something in the text box")

Else

For loopIndexInteger = 0 To maximumInteger

listCompareString = listComboBox.Items(loopIndexInteger).ToString()

listCompareString = listCompareString.ToUpper()

textCompareString = inputTextBox.Text.ToUpper()

If textCompareString.IndexOf(listCompareString) >= 0 Then

matchString &= listCompareString & ControlChars.NewLine

End If

Next loopIndexInteger

If matchString <> "" Then

MessageBox.Show(matchString, "Input That Matches", MessageBoxButtons.OKCancel)

Call clearButton_Click(sender, e)

Else

MessageBox.Show("Nothing matched your input")

Call clearButton_Click(sender, e)

End If
Any help would be appreciated?




Reply With Quote
  #2  
Old November 29th, 2004, 08:40 AM
balaji_sp balaji_sp is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 4 balaji_sp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,

I think the following code will be useful for you to compare the textbox value to listbox value


Dim Str, Str1 AsString
Dim Com AsBoolean

Dim matchString AsString

Dim BoolRes AsInteger

str = LCase(Trim(txt_Customer_Name.Text))

matchString = ""

ForEach Str1 In Listbox1.Items

BoolRes = Str.CompareTo(LCase(Str1))

If BoolRes = 0 Then

matchString &= Str1 & ControlChars.NewLine

EndIf

Next

If matchString <> "" Then

MessageBox.Show(matchString, "Input That Matches", MessageBoxButtons.OKCancel)

Else

MessageBox.Show("Nothing matched your input")

EndIf


Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > Vb.net string question?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT