Forums

ASP

This topic is locked

HELP!!!

Posted 15 Sep 2006 10:18:34
1
has voted
15 Sep 2006 10:18:34 Yna Mrs posted:
hi,
i just wondering, if i were to do a calculation of percentage based on data in my Access Database,
is it possible??

let say i have this two field IN MY DATABASE.MDB

FIELD1 = noResponded
FIELD2 = question1

how can i calculate this into a percentage using vbscript??

is it something like this

<%
Dim percentage1
A=rsnoResponded.RecordCount
B=rsquestion1.RecordCount

percentage1=(B/A)* 100

%>

IF NOT, CAN SOMEBODY HELP ME PLEASE.
THANKS.

Replies

Replied 17 Sep 2006 18:38:17
17 Sep 2006 18:38:17 Wim Conix replied:
Yna,

Should possibly work like you suggest, but to make things easier to display on your page, you can add all calculations directly on the place where it has to be shown...

Something like this :

<%
Respond.Write (rsquestion1_total)/(rsnoResponded_total)*100
%>

This way you don't have to write any vbscript code...

Hope this helps,

Wim

Wim Conix
www.image-belle.com
Replied 19 Sep 2006 05:18:54
19 Sep 2006 05:18:54 Yna Mrs replied:
Hi Wim,
actually, it's not counting.
i want to do the calculation based on data in the field.
let say in field q1=15.
field NoResponded=30

so it should be 15/30 * 100 right?

i'd try the solution both from my side and yours but it has errors.

what i did was something like this:
<%
Dim rs
Set rs= Server.CreateObject("ADODB.Recordset"

Respond.write(rsA15.value)/(rsNoResponded.value) * 100
%> and the error is
Error Type:
Microsoft VBScript runtime (0x800A01A8)
Object required: ''


if follow your previous solution
<%
Respond.Write (rsquestion1_total)/(rsnoResponded_total)*100
%>
this error wil appear
Error Type:
Microsoft VBScript runtime (0x800A0006)
Overflow

so what should i do??
thanks.

Replied 19 Sep 2006 06:55:59
19 Sep 2006 06:55:59 Wim Conix replied:
Hi,

Quick answer, because I have to leave.

For your solution :

DIM and SET are VBScript and may not be placed between the <% ... %> (which is reserved for ASP).
So place these just above the <% ... %> and give that a try...

For the other solution : better send me the asp page, so I can have a closer look at the recordset etc...
You can send this at :
I'll see for it later than.

I'm sure we're gonna find the solution,

Greetzz,

Wim

Wim Conix
www.image-belle.com
Replied 19 Sep 2006 10:02:45
19 Sep 2006 10:02:45 Yna Mrs replied:
Hi Wim,
i made it.
what i did was i put in this code, and it works.

<%
Dim pA5JustNice
pA5JustNice = 0
qA5JustNice=rs("A5JustNice"
NRA5JustNice=rs("NoResponded"
pA5JustNice=(qA5JustNice/NRA5JustNice)* 100
%>
<%=FormatNumber(pA5JustNice, 2)%>%

thanks so much for your reply.
Replied 28 Sep 2006 16:13:34
28 Sep 2006 16:13:34 Vince Baker replied:
Just to add, you can use DIM inside <%%> tags.

Glad you fixed it!

Regards

Vince Baker
<strong>DMX Zone Manager</strong>

[VBScript | ASP | HTML | CSS | SQL | Oracle | AS400 | ERP Logic | Hosting]
Replied 28 Sep 2006 16:22:08
28 Sep 2006 16:22:08 Wim Conix replied:
You're right Vince !
Stupid me, sorry...

Wim

Wim Conix
www.image-belle.com

Reply to this topic