hi, I wanna to calculate the total in currency format $00.00. But the coding doesnt seems to work . Can u help me ?
total = Cstr(total) + Request.Cookies("jumlah")
hi, I wanna to calculate the total in currency format $00.00. But the coding doesnt seems to work . Can u help me ?
total = Cstr(total) + Request.Cookies("jumlah")
The problem is that the value from Request.Cookies is a string (and may include a dollar sign or commas), so converting the running total to a string before adding (as in the original post) will either force concatenation or trigger a type error. Several replies correctly point to using a formatting function for display (, , , ), but none shows a safe, server-side workflow that:
A safe pattern in classic ASP (VBScript) is: read the cookie, strip non-numeric characters that interfere with conversion (dollar sign, thousands separators), check IsNumeric, convert with CDbl (or another numeric cast), add to the numeric total, then format the result for output. Also handle a missing cookie and the possibility of multi-valued cookies.
Example (server-side VBScript):
Dim total, raw, clean
total = 0
raw = Request.Cookies("jumlah")
If raw <> "" Then
clean = Replace(raw, "$", "")
clean = Replace(clean, ",", "")
If IsNumeric(clean) Then
total = total + CDbl(clean)
End If
End If
Response.Write FormatCurrency(total, 2)
Notes and cautions:
Jump to Post— manoshailu 12hi,
CStr is used to Convert from other format to String Format then how can u add the values of the two variables. K. Anyway U can use Format function like below
MsgBox Format("32234324", "$00,00").
Try it
Shailaja:)
Jump to Post— Jx_Man 987use format(MoneyValue,"currency")
hi,
CStr is used to Convert from other format to String Format then how can u add the values of the two variables. K. Anyway U can use Format function like below
MsgBox Format("32234324", "$00,00").
Try it
Shailaja:)
use format(MoneyValue,"currency")
'where 10000000.99 is the Amount
MsgBox Format("10000000.99", "#,###.00") Text1.Text = Format$(CDbl(Format$(Text1.Text, "#,###,##0.00")) + CDbl(Format$(Text2.Text, "#,###,##0.00")), "$###,##0.00")
your comments such a weak./.
all of you is such a weak programmer..
mga bobo!~!!!
Is it so? then give the comment/solution for the thread instead of these type of comments. These comments doesn't make you are a good programmer or wht you expect. k.
Have a great day,
Shailaja :)
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.