By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,419 Members | 1,446 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,419 IT Pros & Developers. It's quick & easy.

VB Like *

P: n/a
Hi

Does anyone know how I can use the Like statement in VB.net and C# .net?

I know it works in VB.net but when I turn on option strict, It doest like it.

How would I use this statement in VB.net and C#

If textbox1.text Like "*Week*" Then
….
End if

If(textbox1.text Like “*Week*”)
{}
I am also looking for the wild card *

Thank you,
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

Use String.IndexOf, for "*something*", String.StartsWith for
"something*" and String.EndsWith for "*something"

HTH,

Sam
On Tue, 8 Mar 2005 13:35:06 -0800, Andr
<An**@discussions.microsoft.com> wrote:
Hi

Does anyone know how I can use the Like statement in VB.net and C# .net?

I know it works in VB.net but when I turn on option strict, It doest like it.

How would I use this statement in VB.net and C#

If textbox1.text Like "*Week*" Then
.
End if

If(textbox1.text Like *Week*)
{}
I am also looking for the wild card *

Thank you,


B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.
Nov 16 '05 #2

P: n/a
"André" <An**@discussions.microsoft.com> schrieb:
Does anyone know how I can use the Like statement in VB.net and C# .net?

I know it works in VB.net but when I turn on option strict, It doest like
it.

How would I use this statement in VB.net and C#

If textbox1.text Like "*Week*" Then
….
End if
The code above compiles with 'Option Strict On'!
If(textbox1.text Like “*Week*”)
{}
I am also looking for the wild card *


There is no 1:1 replacement for 'Like' in the .NET Framework. You may want
to use 'System.Text.RegularExpressions.Regex.IsMatch' instead, which uses a
different syntax for the pattern.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.