using "like" in C#

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2008
Posts: 3
Reputation: msspitul is an unknown quantity at this point 
Solved Threads: 0
msspitul msspitul is offline Offline
Newbie Poster

using "like" in C#

 
0
  #1
May 21st, 2008
msspitul Member since: 5/21/2008 From: Northborough, MA, United States

Posted - 5/21/2008 12:43:01 PM
Hi,

I have a program that was originally in VB that I am trying to convert to C#. I have converted all of it succesfully accept for a part that uses the "like" statement.

The program starts off by having the user enter a file name that they want to work with, then clicking a button so that the file is uploaded and stored in an array. The user can then type in a peice of information into a textbox, click a button, and have the app display a peice of information from the datafile based on what they typed in.


The piece that I am trying to convert looks like this:

For x = 0 To n - 1
With order(x)
If .buyername Like TextBox3.Text & "*" Then
Label5.Text = .title
End If
If .sellername Like TextBox3.Text & "*" Then
Label5.Text = .title
End If
End With
Next

I've looked into many comparisons between VB and C# to see how a process like this could be accomplished in C# and havent found anything. Any suggestions would be greatly appreciated.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,293
Reputation: majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about 
Solved Threads: 67
majestic0110's Avatar
majestic0110 majestic0110 is offline Offline
Nearly a Posting Virtuoso

Re: using "like" in C#

 
0
  #2
May 21st, 2008
Hi there msspitful and welcome to DaniWeb. I had to search on google for this, but I found your answer here:

http://bytes.com/forum/thread242168.html

I hope this helps! Please mark your thread as solved once you get the answer.
If you have a quality, be proud of it and let it define you. Add it to the world!
If you got your answer, please mark the thread as Solved. It saves time when people are looking to contribute threads or for answers!
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 483
Reputation: campkev is an unknown quantity at this point 
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: using "like" in C#

 
0
  #3
May 22nd, 2008
you could also use

buyerName.Contains(TextBox3.Text)
buyerName.BeginsWith(TextBox3.Text)
buyerName.EndsWith(TextBox3.Text)
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 3
Reputation: blovi32 is an unknown quantity at this point 
Solved Threads: 1
blovi32 blovi32 is offline Offline
Newbie Poster

Re: using "like" in C#

 
0
  #4
Jun 5th, 2008
Yes, definitely IndexOf, LastIndexOf, StartsWith and EndsWith. I have a couple articles I wrote about these

http://dotnetperls.com/Content/IndexOf-IndexOfAny.aspx

http://dotnetperls.com/Content/StartsWith-EndsWith.aspx

Of course I don't do VB.NET. Hope this helps a tiny bit

Sam
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC