943,641 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 2421
  • C# RSS
May 21st, 2008
0

using "like" in C#

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
msspitul is offline Offline
3 posts
since May 2008
May 21st, 2008
0

Re: using "like" in C#

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.
Reputation Points: 256
Solved Threads: 72
Nearly a Posting Virtuoso
majestic0110 is offline Offline
1,306 posts
since Oct 2007
May 22nd, 2008
0

Re: using "like" in C#

you could also use

buyerName.Contains(TextBox3.Text)
buyerName.BeginsWith(TextBox3.Text)
buyerName.EndsWith(TextBox3.Text)
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005
Jun 5th, 2008
0

Re: using "like" in C#

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
Reputation Points: 10
Solved Threads: 1
Newbie Poster
blovi32 is offline Offline
3 posts
since Jun 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Making a Single Instance Application Reappear
Next Thread in C# Forum Timeline: Problem with Crystal Report in C# VS2005





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC