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.

you could also use

buyerName.Contains(TextBox3.Text)
buyerName.BeginsWith(TextBox3.Text)
buyerName.EndsWith(TextBox3.Text)

This article has been dead for over six months. Start a new discussion instead.