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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting A Currency

Status
Not open for further replies.

Nosh

Programmer
Jul 12, 2001
34
GB
Hi Folks,

I have the following bit of ASP that loops around a recordset and prints out the contents:

sub query2table(inputquery, inputDSN)
dim conntemp, rstemp
set conntemp=server.createobject("adodb.connection")
conntemp.open inputDSN

set rstemp=Server.CreateObject( "ADODB.Recordset")
rstemp.ActiveConnection = conntemp
rstemp.Open inputQuery
howmanyfields=rstemp.fields.count -1%>
<table border=1><tr>
<% 'Put Headings On The Table of Field Names
for i=0 to howmanyfields %>
<td><b><%=rstemp(i).name%></B></TD>
<% next %>
</tr>
<% ' Now lets grab all the records
do while not rstemp.eof %>
<tr>
<% for i = 0 to howmanyfields
thisvalue=rstemp(i)
If isnull(thisvalue) then
thisvalue=&quot; &quot;
end if
If isNum(thisvalue) then
formatCurrency(thisvalue,2)
end if

%>
<td valign=top><%=thisvalue%></td>
<% next %>
</tr>
<%rstemp.movenext
loop%>
</table>
<%
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
end sub%>

If the value of one of the fields is numeric I want it to be formatted like £0.00. I have tried the formatcurrecny method but it doesn't work - I get the following error:

Cannot use parentheses when calling a Sub
/FillingStation/lib_dbtable.asp, line 27, column 27
formatCurrency(thisvalue,2)

Can anyone help?

Nosh
 
There are two problems here.

First, when you call a function without assigning it to a variable you can not use parentheses. You would write this line of code as:

formatCurrency thisvalue, 2

You won't get an error if you change your code to this but it won't be of much use to you either. You probably want something like the following line of code:

thisvalue = formatCurrency(thisvalue, 2)

Thanks,

Gabe
 
Thats Great Thanks - It is showing the numbers as $0.00 how do I get it to show it as £0.00?

Thanx
 
The currency symbol is determined from the Regional Settings on your web server. You will need to change this in the control panel.

Thanks,

Gabe
 
I'm not sure on the syntax but this is something that might work.

original = setLocale(&quot;gb&quot;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top