Search:
Namespaces
Discussions
.NET v1.1
Feedback
Finding a zero in a string
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngvb' list
.
=?iso-8859-1?Q?Jonathan_Hjertstr=F6m?=
-- 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 =
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 =3D "22,20,0"
Now I want some code to test to see if there is a 0 in this string. Note =
the problem is that since my values are separated with a "," I don't =
want number 20 to show True in the test. Only if there is a 0. Hope you =
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=F6m
K2-Informatics (U) Ltd.
Kampala, Uganda
Reply to this message...
devin
How about this:
If InStr(strOfficerId, ",0") Then
Response.Write("YES THERE IS A ZERO")
End If
Devin
----- Original Message -----
From: =3D?iso-8859-1?Q?Jonathan_Hjertstr=3DF6m?=3D =
<
Click here to reveal e-mail address
>
To:
Click here to reveal e-mail address
Sent: Fri, 7 Jun 2002 20:29:43 +0300
Subject: Finding a zero in a string
[Original message clipped]
Reply to this message...
Patrick Steele
What happens with "10,20,030,40" ?? :)
---
Patrick Steele (
Click here to reveal e-mail address
)
Lead Software Architect
Image Process Design
-----Original Message-----
From: devin [mailto:
Click here to reveal e-mail address
]=20
Sent: Friday, June 07, 2002 2:05 PM
To: aspngvb
Subject: [aspngvb] Re: Finding a zero in a string
How about this:
If InStr(strOfficerId, ",0") Then
Response.Write("YES THERE IS A ZERO")
End If
Devin
----- Original Message -----
From: =3D?iso-8859-1?Q?Jonathan_Hjertstr=3DF6m?=3D
<
Click here to reveal e-mail address
>
To:
Click here to reveal e-mail address
Sent: Fri, 7 Jun 2002 20:29:43 +0300
Subject: Finding a zero in a string
[Original message clipped]
| [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...
Bob Macleod
I would use the Split command with the comma as a delimiter, to separate the
values. (This assumes the values are always separated by commas.) This
ensures that 20 is not detected as a zero. Then test each element against
zero for the answer.
Bob
[Original message clipped]
_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx
Reply to this message...
Tony Kilhoffer
Then use:
If InStr(strOfficerId, ",0,") Then
Response.Write("YES THERE IS A ZERO")
End If
-----Original Message-----
From: Patrick Steele [mailto:
Click here to reveal e-mail address
]
Sent: Friday, June 07, 2002 12:09 PM
To: aspngvb
Subject: [aspngvb] Re: Finding a zero in a string
What happens with "10,20,030,40" ?? :)
---
Patrick Steele (
Click here to reveal e-mail address
)
Lead Software Architect
Image Process Design
-----Original Message-----
From: devin [mailto:
Click here to reveal e-mail address
]
Sent: Friday, June 07, 2002 2:05 PM
To: aspngvb
Subject: [aspngvb] Re: Finding a zero in a string
How about this:
If InStr(strOfficerId, ",0") Then
Response.Write("YES THERE IS A ZERO")
End If
Devin
----- Original Message -----
From: =?iso-8859-1?Q?Jonathan_Hjertstr=F6m?=
<
Click here to reveal e-mail address
>
To:
Click here to reveal e-mail address
Sent: Fri, 7 Jun 2002 20:29:43 +0300
Subject: Finding a zero in a string
[Original message clipped]
| [aspngvb] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngvb.asp
= JOIN/QUIT
| [aspngvb] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngvb.asp
= JOIN/QUIT
Reply to this message...
Rader, Jason
if the string will only be filled by numbers seperated by a comma then =
you could split everything into an array with the comma as the =
separator. Then cast each value to a number and check to see if that =
number =3D 0
Jason
=20
-----Original Message-----
From: Patrick Steele [mailto:
Click here to reveal e-mail address
]
Sent: Friday, June 07, 2002 1:09 PM
To: aspngvb
Subject: [aspngvb] Re: Finding a zero in a string
What happens with "10,20,030,40" ?? :)
---
Patrick Steele (
Click here to reveal e-mail address
)
Lead Software Architect
Image Process Design
-----Original Message-----
From: devin [mailto:
Click here to reveal e-mail address
]=20
Sent: Friday, June 07, 2002 2:05 PM
To: aspngvb
Subject: [aspngvb] Re: Finding a zero in a string
How about this:
If InStr(strOfficerId, ",0") Then
Response.Write("YES THERE IS A ZERO")
End If
Devin
----- Original Message -----
From: =3D?iso-8859-1?Q?Jonathan_Hjertstr=3DF6m?=3D
<
Click here to reveal e-mail address
>
To:
Click here to reveal e-mail address
Sent: Fri, 7 Jun 2002 20:29:43 +0300
Subject: Finding a zero in a string
[Original message clipped]
| [aspngvb] member
Click here to reveal e-mail address
=3D YOUR ID
|
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...
joseph.gaus@dowcorning.com
Well, that would still find "22,02", and would miss "0,22"
You need to make sure the left,2 = "0," or right,2 = ",0" or instr ",0,",
and also check to see if str = "0"
Thanks,
Joe
-----Original Message-----
From: devin [mailto:
Click here to reveal e-mail address
]
Sent: Friday, June 07, 2002 2:05 PM
To: aspngvb
Subject: [aspngvb] Re: Finding a zero in a string
How about this:
If InStr(strOfficerId, ",0") Then
Response.Write("YES THERE IS A ZERO")
End If
Devin
----- Original Message -----
From: =?iso-8859-1?Q?Jonathan_Hjertstr=F6m?= <
Click here to reveal e-mail address
>
To:
Click here to reveal e-mail address
Sent: Fri, 7 Jun 2002 20:29:43 +0300
Subject: Finding a zero in a string
[Original message clipped]
| [aspngvb] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngvb.asp
= JOIN/QUIT
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs SkyScan
service. For more information on a proactive anti-virus service working
around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________
Reply to this message...
Pattam, Prasanna
Put a delimiter at the start of the string and search for ",0,"
The syntax would be
If InStr("," + strOfficerId, ",0,") Then
Response.Write("YES THERE IS A ZERO")
End If
-----Original Message-----
From: Patrick Steele [mailto:
Click here to reveal e-mail address
]
Sent: Friday, June 07, 2002 2:09 PM
To: aspngvb
Subject: [aspngvb] Re: Finding a zero in a string
What happens with "10,20,030,40" ?? :)
---
Patrick Steele (
Click here to reveal e-mail address
)
Lead Software Architect
Image Process Design
-----Original Message-----
From: devin [mailto:
Click here to reveal e-mail address
]
Sent: Friday, June 07, 2002 2:05 PM
To: aspngvb
Subject: [aspngvb] Re: Finding a zero in a string
How about this:
If InStr(strOfficerId, ",0") Then
Response.Write("YES THERE IS A ZERO")
End If
Devin
----- Original Message -----
From: =?iso-8859-1?Q?Jonathan_Hjertstr=F6m?=
<
Click here to reveal e-mail address
>
To:
Click here to reveal e-mail address
Sent: Fri, 7 Jun 2002 20:29:43 +0300
Subject: Finding a zero in a string
[Original message clipped]
| [aspngvb] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngvb.asp
= JOIN/QUIT
| [aspngvb] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngvb.asp
= JOIN/QUIT
Reply to this message...
Thacker, Jason J
You could try
If InStr(strOfficerId, ",0,") Or strOfficerId.EndsWith(",0") Then
Response.Write("YES THERE IS A ZERO")
End If
Because you'll want to catch just a zero or if there's a zero at the end.
-jason
-----Original Message-----
From: Patrick Steele [mailto:
Click here to reveal e-mail address
]
Sent: Friday, June 07, 2002 11:09 AM
To: aspngvb
Subject: [aspngvb] Re: Finding a zero in a string
What happens with "10,20,030,40" ?? :)
---
Patrick Steele (
Click here to reveal e-mail address
)
Lead Software Architect
Image Process Design
-----Original Message-----
From: devin [mailto:
Click here to reveal e-mail address
]
Sent: Friday, June 07, 2002 2:05 PM
To: aspngvb
Subject: [aspngvb] Re: Finding a zero in a string
How about this:
If InStr(strOfficerId, ",0") Then
Response.Write("YES THERE IS A ZERO")
End If
Devin
----- Original Message -----
From: =?iso-8859-1?Q?Jonathan_Hjertstr=F6m?=
<
Click here to reveal e-mail address
>
To:
Click here to reveal e-mail address
Sent: Fri, 7 Jun 2002 20:29:43 +0300
Subject: Finding a zero in a string
[Original message clipped]
| [aspngvb] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngvb.asp
= JOIN/QUIT
| [aspngvb] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngvb.asp
= JOIN/QUIT
Reply to this message...
Tony Kilhoffer
I would also split the values into an array. Its the only bullet-proof way I
can think of.
-----Original Message-----
From: Pattam, Prasanna [mailto:
Click here to reveal e-mail address
]
Sent: Friday, June 07, 2002 12:26 PM
To: aspngvb
Subject: [aspngvb] Re: Finding a zero in a string
Put a delimiter at the start of the string and search for ",0,"
The syntax would be
If InStr("," + strOfficerId, ",0,") Then
Response.Write("YES THERE IS A ZERO")
End If
-----Original Message-----
From: Patrick Steele [mailto:
Click here to reveal e-mail address
]
Sent: Friday, June 07, 2002 2:09 PM
To: aspngvb
Subject: [aspngvb] Re: Finding a zero in a string
What happens with "10,20,030,40" ?? :)
---
Patrick Steele (
Click here to reveal e-mail address
)
Lead Software Architect
Image Process Design
-----Original Message-----
From: devin [mailto:
Click here to reveal e-mail address
]
Sent: Friday, June 07, 2002 2:05 PM
To: aspngvb
Subject: [aspngvb] Re: Finding a zero in a string
How about this:
If InStr(strOfficerId, ",0") Then
Response.Write("YES THERE IS A ZERO")
End If
Devin
----- Original Message -----
From: =?iso-8859-1?Q?Jonathan_Hjertstr=F6m?=
<
Click here to reveal e-mail address
>
To:
Click here to reveal e-mail address
Sent: Fri, 7 Jun 2002 20:29:43 +0300
Subject: Finding a zero in a string
[Original message clipped]
| [aspngvb] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngvb.asp
= JOIN/QUIT
| [aspngvb] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngvb.asp
= JOIN/QUIT
| [aspngvb] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngvb.asp
= JOIN/QUIT
Reply to this message...
isaacs@journalinteractive.com (Scott Isaacs)
an easy way is to prepend and append a comma to the list and remove rogue
spaces
strOfficerId = replace("," & strOfficerId & ",", " ", "")
then you can safely check for ",0," surrounded by commas
if instr(1, strOfficerId, ",0,") >= 1 then
response.write "zero found"
end if
scott
-----Original Message-----
From: Jonathan Hjertström [mailto:
Click here to reveal e-mail address
]
Sent: Friday, June 07, 2002 12:30 PM
To: aspngvb
Subject: [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 =
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 =3D "22,20,0"
Now I want some code to test to see if there is a 0 in this string. Note =
the problem is that since my values are separated with a "," I don't =
want number 20 to show True in the test. Only if there is a 0. Hope you =
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=F6m
K2-Informatics (U) Ltd.
Kampala, Uganda
| [aspngvb] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngvb.asp
= JOIN/QUIT
Reply to this message...
Kevin Finnegan
You could:
Dim strOfficerId As String
strOfficerId = "22,20,0"
nValues = Split(strOfficerId, ",")
t = UBound(nValues)
For x = 0 To t
If CInt(nValues(x)) = 0 Then
bHasAZero = True
End If
Next
This is not the most efficient solution I'm sure, but it will get the job
done
Kevin
-----Original Message-----
From: Jonathan Hjertström [mailto:
Click here to reveal e-mail address
]
Sent: Friday, June 07, 2002 1:30 PM
To: aspngvb
Subject: [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 =
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 =3D "22,20,0"
Now I want some code to test to see if there is a 0 in this string. Note =
the problem is that since my values are separated with a "," I don't =
want number 20 to show True in the test. Only if there is a 0. Hope you =
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=F6m
K2-Informatics (U) Ltd.
Kampala, Uganda
| [aspngvb] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngvb.asp
= JOIN/QUIT
Reply to this message...
Shaffer, Jereme
Dim RegExp
Set RegExp =3D New RegExp
RegExp.Pattern =3D "^0\,|^0$|,0,|,0$"
If RegExp.Test(strOfficerID) =3D True Then
Response.Write ("YES THERE IS A ZERO")
End If
Set RegExp =3D Nothing
Jereme
-----Original Message-----
From: Kevin Finnegan [mailto:
Click here to reveal e-mail address
]=20
Sent: Friday, June 07, 2002 2:54 PM
To: aspngvb
Subject: [aspngvb] RE: Finding a zero in a string
You could:
Dim strOfficerId As String
strOfficerId =3D "22,20,0"
nValues =3D Split(strOfficerId, ",")
t =3D UBound(nValues)
For x =3D 0 To t
If CInt(nValues(x)) =3D 0 Then
bHasAZero =3D True
End If
Next
This is not the most efficient solution I'm sure, but it will get the =
job
done
Kevin
-----Original Message-----
From: Jonathan Hjertstr=F6m [mailto:
Click here to reveal e-mail address
]
Sent: Friday, June 07, 2002 1:30 PM
To: aspngvb
Subject: [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
|
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...
Thacker, Jason J
You could try
If InStr(strOfficerId, ",0,") Or strOfficerId.EndsWith(",0") or
strOfficerId.startswith("0,") Then
Response.Write("YES THERE IS A ZERO")
End If
Because you'll want to catch just a zero or if there's a zero at the end and
at the beginning!
-jason
-----Original Message-----
From: Patrick Steele [mailto:
Click here to reveal e-mail address
]
Sent: Friday, June 07, 2002 11:09 AM
To: aspngvb
Subject: [aspngvb] Re: Finding a zero in a string
What happens with "10,20,030,40" ?? :)
---
Patrick Steele (
Click here to reveal e-mail address
)
Lead Software Architect
Image Process Design
-----Original Message-----
From: devin [mailto:
Click here to reveal e-mail address
]
Sent: Friday, June 07, 2002 2:05 PM
To: aspngvb
Subject: [aspngvb] Re: Finding a zero in a string
How about this:
If InStr(strOfficerId, ",0") Then
Response.Write("YES THERE IS A ZERO")
End If
Devin
----- Original Message -----
From: =?iso-8859-1?Q?Jonathan_Hjertstr=F6m?=
<
Click here to reveal e-mail address
>
To:
Click here to reveal e-mail address
Sent: Fri, 7 Jun 2002 20:29:43 +0300
Subject: Finding a zero in a string
[Original message clipped]
| [aspngvb] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngvb.asp
= JOIN/QUIT
| [aspngvb] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngvb.asp
= JOIN/QUIT
| [aspngvb] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/asplists/aspngvb.asp
= 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