16 个解决方案
#1
#2
select sum(my_field) from my_table where
#3
问题就是 my_field 怎么取 比如我点在A列 那么 A列的字段名该如何传递进去?
#4
也可以从头到尾计算
while not rs.eof
sumT=sumT + rs.fields("my_field")
rs.movenext
while not rs.eof
sumT=sumT + rs.fields("my_field")
rs.movenext
#5
我现在只有一个 TEXT 有很多列 Text 里面显示对哪一列的求和取决于我鼠标 位于那一列上 这一列并不是固定的
#6
自己顶!!
#7
Private Sub DataGrid1_HeadClick(ByVal ColIndex As Integer)
Dim i As Integer
Dim sumT As Long
DataGrid1.Col = ColIndex
For i = 0 To Adodc1.Recordset.RecordCount - 1
DataGrid1.Row = i
sumT = sumT + DataGrid1.Text
Next i
Debug.Print sumT
End Sub
#8
DataGrid1.Col = ColIndex 这个是什么意思?
怎么把结果显示在TEXT中呢? 谢谢 我新手
#9
Private Sub DataGrid1_HeadClick(ByVal ColIndex As Integer)
Dim i As Integer
Dim sumT As Long
DataGrid1.Col = ColIndex
For i = 0 To Adodc1.Recordset.RecordCount - 1
DataGrid1.Row = i
sumT = sumT + DataGrid1.Text
Next i
text1.text= sumT
End Sub
#10
sumT = sumT + DataGrid1.Text 编译是错误 这句话“类型不匹配”
#11
#12
自己顶啊!
#13
Dim sumT As Long
**************
改成你的类型,比如double
**************
改成你的类型,比如double
#14
各位大师,这代码可以帮忙加点;容错代码;我选择其他不是数字段就报错误
#15
小弟编成菜鸟,可以在给点代码
#16
sumT = sumT + DataGrid1.Text 编译是错误 这句话“类型不匹配”
我帮你调试出来了:
通过val 把字符转换一下,就通用了统计所有行有数值的不报错误
代码如下:
Private Sub DataGrid1_HeadClick(ByVal ColIndex As Integer)
Dim i As Integer
Dim sumT As double
DataGrid1.Col = ColIndex
For i = 0 To Adodc1.Recordset.RecordCount - 1
DataGrid1.Row = i
sumT = val(sumT) +val( DataGrid1.Text) '改转换一下字符
Next i
text1.text= sumT
End Sub
我帮你调试出来了:
通过val 把字符转换一下,就通用了统计所有行有数值的不报错误
代码如下:
Private Sub DataGrid1_HeadClick(ByVal ColIndex As Integer)
Dim i As Integer
Dim sumT As double
DataGrid1.Col = ColIndex
For i = 0 To Adodc1.Recordset.RecordCount - 1
DataGrid1.Row = i
sumT = val(sumT) +val( DataGrid1.Text) '改转换一下字符
Next i
text1.text= sumT
End Sub
#1
#2
select sum(my_field) from my_table where
#3
问题就是 my_field 怎么取 比如我点在A列 那么 A列的字段名该如何传递进去?
#4
也可以从头到尾计算
while not rs.eof
sumT=sumT + rs.fields("my_field")
rs.movenext
while not rs.eof
sumT=sumT + rs.fields("my_field")
rs.movenext
#5
我现在只有一个 TEXT 有很多列 Text 里面显示对哪一列的求和取决于我鼠标 位于那一列上 这一列并不是固定的
#6
自己顶!!
#7
Private Sub DataGrid1_HeadClick(ByVal ColIndex As Integer)
Dim i As Integer
Dim sumT As Long
DataGrid1.Col = ColIndex
For i = 0 To Adodc1.Recordset.RecordCount - 1
DataGrid1.Row = i
sumT = sumT + DataGrid1.Text
Next i
Debug.Print sumT
End Sub
#8
DataGrid1.Col = ColIndex 这个是什么意思?
怎么把结果显示在TEXT中呢? 谢谢 我新手
#9
Private Sub DataGrid1_HeadClick(ByVal ColIndex As Integer)
Dim i As Integer
Dim sumT As Long
DataGrid1.Col = ColIndex
For i = 0 To Adodc1.Recordset.RecordCount - 1
DataGrid1.Row = i
sumT = sumT + DataGrid1.Text
Next i
text1.text= sumT
End Sub
#10
sumT = sumT + DataGrid1.Text 编译是错误 这句话“类型不匹配”
#11
#12
自己顶啊!
#13
Dim sumT As Long
**************
改成你的类型,比如double
**************
改成你的类型,比如double
#14
各位大师,这代码可以帮忙加点;容错代码;我选择其他不是数字段就报错误
#15
小弟编成菜鸟,可以在给点代码
#16
sumT = sumT + DataGrid1.Text 编译是错误 这句话“类型不匹配”
我帮你调试出来了:
通过val 把字符转换一下,就通用了统计所有行有数值的不报错误
代码如下:
Private Sub DataGrid1_HeadClick(ByVal ColIndex As Integer)
Dim i As Integer
Dim sumT As double
DataGrid1.Col = ColIndex
For i = 0 To Adodc1.Recordset.RecordCount - 1
DataGrid1.Row = i
sumT = val(sumT) +val( DataGrid1.Text) '改转换一下字符
Next i
text1.text= sumT
End Sub
我帮你调试出来了:
通过val 把字符转换一下,就通用了统计所有行有数值的不报错误
代码如下:
Private Sub DataGrid1_HeadClick(ByVal ColIndex As Integer)
Dim i As Integer
Dim sumT As double
DataGrid1.Col = ColIndex
For i = 0 To Adodc1.Recordset.RecordCount - 1
DataGrid1.Row = i
sumT = val(sumT) +val( DataGrid1.Text) '改转换一下字符
Next i
text1.text= sumT
End Sub