SV: Finding a zero in a string
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngvb' list.


=?iso-8859-1?Q?Andr=E9_Colbi=F6rnsen?=
Here you go, use regular expressions:

        Dim strString As String =3D "22,20,1" 'This is a no
        strString =3D Replace(strString,","," ")
        Dim objRegexp As RegEx
        objRegexp =3D New RegEx("\b0{1}\b")
    =09
        If objRegexp.IsMatch(strString) Then
            Response.write("Yes")
        Else
            Response.write("No")
        End If=09

(Vilken diskussion du satte ig=E5ng)

Regards/Halsningar

Andre Colbiornsen
--------------------------------------
Sonnenburg Communications
Bergsgatan 3,
SE-211 54 Malm=F6
Sweden
Tel.: +46-(0)40-97 78 80
Fax.: +46-(0)40-97 78 80
Mob.: +46-(0)708-97 78 79
Mail: Click here to reveal e-mail address
Web.: www.sonnenburg.se
--------------------------------------
B2B Web agency - Specializing on .Net
--------------------------------------

-----Ursprungligt meddelande-----
Fr=E5n: Jonathan Hjertstr=F6m [mailto:Click here to reveal e-mail address]=20
Skickat: den 7 juni 2002 19:30
Till: aspngvb
=C4mne: [aspngvb] Finding a zero in a string

-- Moved from [aspngfreeforall] to [aspngvb] by devin
<Click here to reveal e-mail address> --

Hi,

This is probably something very simple but I am too tired now to figure
=3D it out. Could someone help me in finding a zero in a string?

Let's say I have a string like this

Dim strOfficerId As String =3D3D "22,20,0"

Now I want some code to test to see if there is a 0 in this string. Note
=3D the problem is that since my values are separated with a "," I don't =
=3D
want number 20 to show True in the test. Only if there is a 0. Hope you
=3D understand what I am trying to do.

I tried with this code that ofcourse would not work:
If InStr(strOfficerId, "0") Then
Response.Write("YES THERE IS A ZERO")
End If

Many thanks!

Jonathan Hjertstr=3DF6m
K2-Informatics (U) Ltd.
Kampala, Uganda
| [aspngvb] member Click here to reveal e-mail address =3D YOUR ID=20
| http://www.asplists.com/asplists/aspngvb.asp =3D JOIN/QUIT

Reply to this message...
 
    
=?iso-8859-1?Q?Jonathan_Hjertstr=F6m?=
Thank you very much.=20

I used the code from Andr=E9 below and it worked excellent.

Many thanks to all of you!

Best regards,
Jonathan Hjertstr=F6m
K2-Informatics (U) Ltd.
Kampala, Uganda

-----Original Message-----
From: Andr=E9 Colbi=F6rnsen [mailto:Click here to reveal e-mail address]=20
Sent: den 7 juni 2002 21:56
To: aspngvb
Subject: [aspngvb] SV: Finding a zero in a string

Here you go, use regular expressions:

        Dim strString As String =3D "22,20,1" 'This is a no
        strString =3D Replace(strString,","," ")
        Dim objRegexp As RegEx
        objRegexp =3D New RegEx("\b0{1}\b")
    =09
        If objRegexp.IsMatch(strString) Then
            Response.write("Yes")
        Else
            Response.write("No")
        End If=09

(Vilken diskussion du satte ig=E5ng)

Regards/Halsningar

Andre Colbiornsen
--------------------------------------
Sonnenburg Communications
Bergsgatan 3,
SE-211 54 Malm=F6
Sweden
Tel.: +46-(0)40-97 78 80
Fax.: +46-(0)40-97 78 80
Mob.: +46-(0)708-97 78 79
Mail: Click here to reveal e-mail address
Web.: www.sonnenburg.se
--------------------------------------
B2B Web agency - Specializing on .Net
--------------------------------------

-----Ursprungligt meddelande-----
Fr=E5n: Jonathan Hjertstr=F6m [mailto:Click here to reveal e-mail address]=20
Skickat: den 7 juni 2002 19:30
Till: aspngvb
=C4mne: [aspngvb] Finding a zero in a string

-- Moved from [aspngfreeforall] to [aspngvb] by devin
<Click here to reveal e-mail address> --

Hi,

This is probably something very simple but I am too tired now to figure
=3D it out. Could someone help me in finding a zero in a string?

Let's say I have a string like this

Dim strOfficerId As String =3D3D "22,20,0"

Now I want some code to test to see if there is a 0 in this string. Note
=3D the problem is that since my values are separated with a "," I don't =
=3D
want number 20 to show True in the test. Only if there is a 0. Hope you
=3D understand what I am trying to do.

I tried with this code that ofcourse would not work:
If InStr(strOfficerId, "0") Then
Response.Write("YES THERE IS A ZERO")
End If

Many thanks!

Jonathan Hjertstr=3DF6m
K2-Informatics (U) Ltd.
Kampala, Uganda
| [aspngvb] member Click here to reveal e-mail address =3D YOUR ID=20
| http://www.asplists.com/asplists/aspngvb.asp =3D JOIN/QUIT

| [aspngvb] member Click here to reveal e-mail address =3D YOUR ID
| http://www.asplists.com/asplists/aspngvb.asp =3D JOIN/QUIT

Reply to this message...
 
 




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com