Replace: Problems stripping out Comma for a Integer field
Replace: Problems stripping out Comma for a Integer field
am 09.09.2005 17:06:53 von jason
Interesting problem: If a user puts a Comma into an integer field I will get
a data type error.
I tried Replacing it with a blank space:
FUNCTION FixApos(Var)
FixApos=Replace(Var, "'", "")
FixApos=Replace(Var, ",", "")
END FUNCTION
But still pick up the error. Is tis because the Int field sees the empty
space as a 'character'?
I have no resorted to redirecting user back to form page if there is a comma
detected:
FUNCTION FixApos(Var)
FixApos=Replace(Var, "'", "")
FixApos=Replace(Var, ",", "")
If Instr(Var,",") then
response.redirect "FormAdd.asp?Error=Comma"
End If
' this replaces a single apostrophe ( ' ) with two single apostrophes ( '').
Note: two single apostrophes, not one quotation mark
END FUNCTION
Bsides client side validation there surely has to be a better way to strip
out commas for an integer field on the fly. I also tried replacing with a
NULL but error said this was inproper use of Replace function.
Could really use some help here.
Thanks
Jason
Re: Replace: Problems stripping out Comma for a Integer field
am 09.09.2005 18:07:58 von jason
In the end, I resorted to changing the data types in my table from INT to
VarChar......this will cause certain reporting and extraction challenges
later - oh well :)
wrote in message
news:udjWeAVtFHA.1168@TK2MSFTNGP11.phx.gbl...
> Interesting problem: If a user puts a Comma into an integer field I will
> get a data type error.
>
> I tried Replacing it with a blank space:
>
> FUNCTION FixApos(Var)
> FixApos=Replace(Var, "'", "")
> FixApos=Replace(Var, ",", "")
>
> END FUNCTION
>
> But still pick up the error. Is tis because the Int field sees the empty
> space as a 'character'?
>
> I have no resorted to redirecting user back to form page if there is a
> comma detected:
>
> FUNCTION FixApos(Var)
> FixApos=Replace(Var, "'", "")
> FixApos=Replace(Var, ",", "")
> If Instr(Var,",") then
>
> response.redirect "FormAdd.asp?Error=Comma"
>
> End If
> ' this replaces a single apostrophe ( ' ) with two single apostrophes (
> ''). Note: two single apostrophes, not one quotation mark
> END FUNCTION
>
>
> Bsides client side validation there surely has to be a better way to strip
> out commas for an integer field on the fly. I also tried replacing with a
> NULL but error said this was inproper use of Replace function.
>
> Could really use some help here.
>
> Thanks
> Jason
>
Re: Replace: Problems stripping out Comma for a Integer field
am 09.09.2005 18:25:32 von reb01501
Why not simply use CInt to convert the value to an integer?? Or CLng to
convert it to a long?
jason@catamaranco.com wrote:
> Interesting problem: If a user puts a Comma into an integer field I
> will get a data type error.
>
> I tried Replacing it with a blank space:
>
> FUNCTION FixApos(Var)
> FixApos=Replace(Var, "'", "")
> FixApos=Replace(Var, ",", "")
>
> END FUNCTION
>
> But still pick up the error. Is tis because the Int field sees the
> empty space as a 'character'?
>
> I have no resorted to redirecting user back to form page if there is
> a comma detected:
>
> FUNCTION FixApos(Var)
> FixApos=Replace(Var, "'", "")
> FixApos=Replace(Var, ",", "")
> If Instr(Var,",") then
>
> response.redirect "FormAdd.asp?Error=Comma"
>
> End If
> ' this replaces a single apostrophe ( ' ) with two single apostrophes
> ( ''). Note: two single apostrophes, not one quotation mark
> END FUNCTION
>
>
> Bsides client side validation there surely has to be a better way to
> strip out commas for an integer field on the fly. I also tried
> replacing with a NULL but error said this was inproper use of Replace
> function.
>
> Could really use some help here.
>
> Thanks
> Jason
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Re: Replace: Problems stripping out Comma for a Integer field
am 10.09.2005 00:59:05 von Bob Lehmann
How are you passing the Var argument to the FixPos Function? Unless you have
it in quotes FixApos("1,000"), you will get an error.
And why is the function named FixApos? Even if all it did was escape
apostrophes, wouldn't a better name be FixApostrophes, or my favorite -
FixTix?
When I first looked at it, I was wondering what an Apo was.
Bob Lehmann
wrote in message
news:udjWeAVtFHA.1168@TK2MSFTNGP11.phx.gbl...
> Interesting problem: If a user puts a Comma into an integer field I will
get
> a data type error.
>
> I tried Replacing it with a blank space:
>
> FUNCTION FixApos(Var)
> FixApos=Replace(Var, "'", "")
> FixApos=Replace(Var, ",", "")
>
> END FUNCTION
>
> But still pick up the error. Is tis because the Int field sees the empty
> space as a 'character'?
>
> I have no resorted to redirecting user back to form page if there is a
comma
> detected:
>
> FUNCTION FixApos(Var)
> FixApos=Replace(Var, "'", "")
> FixApos=Replace(Var, ",", "")
> If Instr(Var,",") then
>
> response.redirect "FormAdd.asp?Error=Comma"
>
> End If
> ' this replaces a single apostrophe ( ' ) with two single apostrophes (
'').
> Note: two single apostrophes, not one quotation mark
> END FUNCTION
>
>
> Bsides client side validation there surely has to be a better way to strip
> out commas for an integer field on the fly. I also tried replacing with a
> NULL but error said this was inproper use of Replace function.
>
> Could really use some help here.
>
> Thanks
> Jason
>
>
Re: Replace: Problems stripping out Comma for a Integer field
am 12.09.2005 16:00:36 von jason
I tried that - and it did not work!
"Bob Barrows [MVP]" wrote in message
news:uJkabsVtFHA.3896@TK2MSFTNGP15.phx.gbl...
> Why not simply use CInt to convert the value to an integer?? Or CLng to
> convert it to a long?
>
> jason@catamaranco.com wrote:
>> Interesting problem: If a user puts a Comma into an integer field I
>> will get a data type error.
>>
>> I tried Replacing it with a blank space:
>>
>> FUNCTION FixApos(Var)
>> FixApos=Replace(Var, "'", "")
>> FixApos=Replace(Var, ",", "")
>>
>> END FUNCTION
>>
>> But still pick up the error. Is tis because the Int field sees the
>> empty space as a 'character'?
>>
>> I have no resorted to redirecting user back to form page if there is
>> a comma detected:
>>
>> FUNCTION FixApos(Var)
>> FixApos=Replace(Var, "'", "")
>> FixApos=Replace(Var, ",", "")
>> If Instr(Var,",") then
>>
>> response.redirect "FormAdd.asp?Error=Comma"
>>
>> End If
>> ' this replaces a single apostrophe ( ' ) with two single apostrophes
>> ( ''). Note: two single apostrophes, not one quotation mark
>> END FUNCTION
>>
>>
>> Bsides client side validation there surely has to be a better way to
>> strip out commas for an integer field on the fly. I also tried
>> replacing with a NULL but error said this was inproper use of Replace
>> function.
>>
>> Could really use some help here.
>>
>> Thanks
>> Jason
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>
Re: Replace: Problems stripping out Comma for a Integer field
am 12.09.2005 16:02:24 von jason
Yes, its being passed a variable hence I do need to use quotation marks.
You are correct about the naming convention - but at first I was only
converned with apos. until this int problem showed up :)
"Bob Lehmann" wrote in message
news:OsMiUHZtFHA.2008@TK2MSFTNGP10.phx.gbl...
> How are you passing the Var argument to the FixPos Function? Unless you
> have
> it in quotes FixApos("1,000"), you will get an error.
>
> And why is the function named FixApos? Even if all it did was escape
> apostrophes, wouldn't a better name be FixApostrophes, or my favorite -
> FixTix?
>
> When I first looked at it, I was wondering what an Apo was.
>
> Bob Lehmann
>
> wrote in message
> news:udjWeAVtFHA.1168@TK2MSFTNGP11.phx.gbl...
>> Interesting problem: If a user puts a Comma into an integer field I will
> get
>> a data type error.
>>
>> I tried Replacing it with a blank space:
>>
>> FUNCTION FixApos(Var)
>> FixApos=Replace(Var, "'", "")
>> FixApos=Replace(Var, ",", "")
>>
>> END FUNCTION
>>
>> But still pick up the error. Is tis because the Int field sees the empty
>> space as a 'character'?
>>
>> I have no resorted to redirecting user back to form page if there is a
> comma
>> detected:
>>
>> FUNCTION FixApos(Var)
>> FixApos=Replace(Var, "'", "")
>> FixApos=Replace(Var, ",", "")
>> If Instr(Var,",") then
>>
>> response.redirect "FormAdd.asp?Error=Comma"
>>
>> End If
>> ' this replaces a single apostrophe ( ' ) with two single apostrophes (
> '').
>> Note: two single apostrophes, not one quotation mark
>> END FUNCTION
>>
>>
>> Bsides client side validation there surely has to be a better way to
>> strip
>> out commas for an integer field on the fly. I also tried replacing with a
>> NULL but error said this was inproper use of Replace function.
>>
>> Could really use some help here.
>>
>> Thanks
>> Jason
>>
>>
>
>
Re: Replace: Problems stripping out Comma for a Integer field
am 12.09.2005 16:38:49 von reb01501
What does that mean?
jason@catamaranco.com wrote:
> I tried that - and it did not work!
>
> "Bob Barrows [MVP]" wrote in message
> news:uJkabsVtFHA.3896@TK2MSFTNGP15.phx.gbl...
>> Why not simply use CInt to convert the value to an integer?? Or CLng
>> to convert it to a long?
>>
>> jason@catamaranco.com wrote:
>>> Interesting problem: If a user puts a Comma into an integer field I
>>> will get a data type error.
>>>
>>> I tried Replacing it with a blank space:
>>>
>>> FUNCTION FixApos(Var)
>>> FixApos=Replace(Var, "'", "")
>>> FixApos=Replace(Var, ",", "")
>>>
>>> END FUNCTION
>>>
>>> But still pick up the error. Is tis because the Int field sees the
>>> empty space as a 'character'?
>>>
>>> I have no resorted to redirecting user back to form page if there is
>>> a comma detected:
>>>
>>> FUNCTION FixApos(Var)
>>> FixApos=Replace(Var, "'", "")
>>> FixApos=Replace(Var, ",", "")
>>> If Instr(Var,",") then
>>>
>>> response.redirect "FormAdd.asp?Error=Comma"
>>>
>>> End If
>>> ' this replaces a single apostrophe ( ' ) with two single
>>> apostrophes ( ''). Note: two single apostrophes, not one quotation
>>> mark
>>> END FUNCTION
>>>
>>>
>>> Bsides client side validation there surely has to be a better way to
>>> strip out commas for an integer field on the fly. I also tried
>>> replacing with a NULL but error said this was inproper use of
>>> Replace function.
>>>
>>> Could really use some help here.
>>>
>>> Thanks
>>> Jason
>>
>> --
>> Microsoft MVP -- ASP/ASP.NET
>> Please reply to the newsgroup. The email account listed in my From
>> header is my spam trap, so I don't check it very often. You will get
>> a quicker response by posting to the newsgroup.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Re: Replace: Problems stripping out Comma for a Integer field
am 12.09.2005 20:59:25 von mdkersey
jason@catamaranco.com wrote:
> Interesting problem: If a user puts a Comma into an integer field I will get
> a data type error.
>
> I tried Replacing it with a blank space:
Code should not change data in a correctly- or incorrectly-entered form
field (unless it notifies the user and asks permission).
The user made a mistake. Modify the code to trap the error and prompt
the user for correct entry.
Re: Replace: Problems stripping out Comma for a Integer field
am 13.09.2005 00:24:39 von reb01501
Look. Go back to the beginning and show us how you get the data type error.
intvar= clng("1,568")
should "work", at least, it does for me.
Bob Barrows
jason@catamaranco.com wrote:
> Interesting problem: If a user puts a Comma into an integer field I
> will get a data type error.
>
> I tried Replacing it with a blank space:
>
> FUNCTION FixApos(Var)
> FixApos=Replace(Var, "'", "")
> FixApos=Replace(Var, ",", "")
>
> END FUNCTION
>
> But still pick up the error. Is tis because the Int field sees the
> empty space as a 'character'?
>
> I have no resorted to redirecting user back to form page if there is
> a comma detected:
>
> FUNCTION FixApos(Var)
> FixApos=Replace(Var, "'", "")
> FixApos=Replace(Var, ",", "")
> If Instr(Var,",") then
>
> response.redirect "FormAdd.asp?Error=Comma"
>
> End If
> ' this replaces a single apostrophe ( ' ) with two single apostrophes
> ( ''). Note: two single apostrophes, not one quotation mark
> END FUNCTION
>
>
> Bsides client side validation there surely has to be a better way to
> strip out commas for an integer field on the fly. I also tried
> replacing with a NULL but error said this was inproper use of Replace
> function.
> Could really use some help here.
>
> Thanks
> Jason
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Re: Replace: Problems stripping out Comma for a Integer field
am 13.09.2005 01:53:49 von Bob Lehmann
Your function works fine, as written, for me.
Bob Lehmann
wrote in message
news:%23p69ZK6tFHA.2064@TK2MSFTNGP09.phx.gbl...
> Yes, its being passed a variable hence I do need to use quotation marks.
>
> You are correct about the naming convention - but at first I was only
> converned with apos. until this int problem showed up :)
> "Bob Lehmann" wrote in message
> news:OsMiUHZtFHA.2008@TK2MSFTNGP10.phx.gbl...
> > How are you passing the Var argument to the FixPos Function? Unless you
> > have
> > it in quotes FixApos("1,000"), you will get an error.
> >
> > And why is the function named FixApos? Even if all it did was escape
> > apostrophes, wouldn't a better name be FixApostrophes, or my favorite -
> > FixTix?
> >
> > When I first looked at it, I was wondering what an Apo was.
> >
> > Bob Lehmann
> >
> > wrote in message
> > news:udjWeAVtFHA.1168@TK2MSFTNGP11.phx.gbl...
> >> Interesting problem: If a user puts a Comma into an integer field I
will
> > get
> >> a data type error.
> >>
> >> I tried Replacing it with a blank space:
> >>
> >> FUNCTION FixApos(Var)
> >> FixApos=Replace(Var, "'", "")
> >> FixApos=Replace(Var, ",", "")
> >>
> >> END FUNCTION
> >>
> >> But still pick up the error. Is tis because the Int field sees the
empty
> >> space as a 'character'?
> >>
> >> I have no resorted to redirecting user back to form page if there is a
> > comma
> >> detected:
> >>
> >> FUNCTION FixApos(Var)
> >> FixApos=Replace(Var, "'", "")
> >> FixApos=Replace(Var, ",", "")
> >> If Instr(Var,",") then
> >>
> >> response.redirect "FormAdd.asp?Error=Comma"
> >>
> >> End If
> >> ' this replaces a single apostrophe ( ' ) with two single apostrophes (
> > '').
> >> Note: two single apostrophes, not one quotation mark
> >> END FUNCTION
> >>
> >>
> >> Bsides client side validation there surely has to be a better way to
> >> strip
> >> out commas for an integer field on the fly. I also tried replacing with
a
> >> NULL but error said this was inproper use of Replace function.
> >>
> >> Could really use some help here.
> >>
> >> Thanks
> >> Jason
> >>
> >>
> >
> >
>
>