使用MSHFlexGrid控件,用Set MSHFlexGrid1.DataSource = rs绑定数据库 ,如何统计控件某列的和
解决方案 »
- SkinH_VB6.dll皮肤包在win7下的显示问题
- 关于Webbrower 给网页中TEXT赋值的问题。(UP有分,如果方法可行单独再给200分)
- 一定要先通过网上邻居登陆到对方的电脑才能访问他的SQLSERVER?
- 无聊,散分
- MD5加密那位仁兄可以给出一个函传递密码就可以进行加密后输入数据库?
- 更新大量数据时,程序很慢,像死了一样。。。怎么办?
- 求救,winsock组件在服务器上出错。:(
- *******ASP*************????????
- 关于.........ImageComBo....谁就讲清楚.........道明白??
- 在vb中如何运行sql命令如:update cwgl set jsr='llpp';
- 枚举注册表某个节点下的所有子节点名称,怎么做
- 请教,在线等!急急!!!!!
dim count as long
Dim iAs Integer
Dim j As Integer
count = 0
i = MSHFlexGrid1.Rows - 1
For j = 1 To i
count = CLng(count) + CLng(Val(Grid.TextMatrix(j, 6)))
Next
速度很快的,可以忽略不计。
Public Sub CountGrid(sGrid As MSFlexGrid)
'工作量统计的表格,用于统计合计项
Dim sng1 As Single, sng2 As Single, I As Long, J As Long, K As Long, L As Long
J = sGrid.Rows - 1
L = sGrid.Cols - 1
If J <= 0 Then Exit Sub
sGrid.Redraw = False
sGrid.Rows = J + 2
sGrid.TextMatrix(J + 1, 0) = "总计:" For K = 1 To L
sng1 = 0
For I = 1 To J
If Len(sGrid.TextMatrix(I, K)) > 0 Then
sng1 = sng1 + CSng(sGrid.TextMatrix(I, K))
End If
Next I
sGrid.TextMatrix(J + 1, K) = Format(sng1, "###,##0.00")
Next K
sGrid.Redraw = True
End Sub
sql="select a1,a3,...from table1 where a1='' union select sum(a1),sum(a2),sum(a3)..."
rs.open sql,db,,,
也可以统计mshgrid 中的列
dim x as intger
mshgrid1.col=1 '你要统计的列
for i=0 to mshgrid1.rows-1
mshgrid1.row=i
x=x+val(mshgrid1.text)
next
debug.print x 最后的结果!!
用Mshflexgrid比较好
如 sum=sum+Val(Me.MSHFlexGrid1.TextMatrix(i, j))