vb 6 DataGrid

S

skahala

Dear Sir ,

I am displaying Amount in DataGrid in a column called
Total. I want to calculate Grand Total and display it in a
text box how do i loop through DataGrid to Claculate the
Grand Total.

thanx
 
S

Scott

Copy and paste this into a new asp page, and hopefully you will get
the general idea:

<%@ Language=VBScript %>
<HTML>
<HEAD></HEAD>
<BODY>
<TABLE BORDER=1>
<%
Dim oItems, oTot
oTot = 0
oItems = 3 'Make this equal to the # of items RS1.RecordCount
For i = 1 To oItems
oTot = oTot + 5 'Make this equal to RS1("ItemValue")
%>
<TR>
<TD>Item <%=i%></TD>
<TD><%="5"%><%'Make this equal to RS1("ItemValue")%></TD>
</TR>
<%
Next
%>
<TR>
<TD>Total Items</TD>
<TD><%=oItems%></TD>
</TR>
<TR>
<TD>Total Cost</TD>
<TD><%=oTot%></TD>
</TR>
</TABLE>
</BODY>
</HTML>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top