Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting to Money

Status
Not open for further replies.

mdr227

Programmer
Nov 17, 2000
114
US
On a data entry form I am asking users to enter a dollar amount. How can I convert the value they enter if it includes commas to a money or numeric format?
 
dim moneyVar
moneyVar = request.form("theTextField")
moneyVar = replace(moneyVar, "$", "")
moneyVar = replace(moneyVar, ",", "")
on error resume next
moneyVar = cdbl(moneyVar)
if err.number <> 0 then
'your entry was not numeric, so do something
end if
err.clear
on error goto 0

Gives you a nice variable of subtype, double, that should be suited for entry into a database field -- and if the entry was not numeric, you've handled that, as well.

:)
Paul Prewett
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top