VB Like *

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • André

    #1

    VB Like *

    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.tex t Like “*Week*”)
    {}
    I am also looking for the wild card *

    Thank you,
  • Samuel R. Neff

    #2
    Re: VB Like *


    Use String.IndexOf, for "*something *", String.StartsWi th for
    "something* " and String.EndsWith for "*something "

    HTH,

    Sam


    On Tue, 8 Mar 2005 13:35:06 -0800, André
    <Andr@discussio ns.microsoft.co m> wrote:
    [color=blue]
    >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.te xt Like “*Week*”)
    >{}
    >I am also looking for the wild card *
    >
    >Thank you,[/color]

    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.

    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: VB Like *

      "André" <Andr@discussio ns.microsoft.co m> schrieb:[color=blue]
      > 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[/color]

      The code above compiles with 'Option Strict On'!
      [color=blue]
      > If(textbox1.tex t Like “*Week*”)
      > {}
      > I am also looking for the wild card *[/color]

      There is no 1:1 replacement for 'Like' in the .NET Framework. You may want
      to use 'System.Text.Re gularExpression s.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/>

      Comment

      Working...