一段代码,在窗口的文本框显示数量及百分比,打开项目出错,如何解决,请各位老师指教。谢谢!!
代码如下:
劳动报酬_DataColChanged
'在册人数
Select Case e.DataCol.Name
Case "本单位"
If Forms("劳动报酬").Opened Then
Forms("劳动报酬").Controls("TextBox1").value = DataTables("劳动报酬").compute("Count([单位])","姓名 <> '""'")
End If
End Select
'评定等级
Select Case e.DataCol.Name
Case "评定等级"
If Forms("劳动报酬").Opened Then
Forms("劳动报酬").Controls("TextBox2").value = DataTables("劳动报酬").compute("Count([单位])","评定等级 = 'A'")
Forms("劳动报酬").Controls("TextBox3").value = DataTables("劳动报酬").compute("Count([单位])","评定等级 = 'B'")
Forms("劳动报酬").Controls("TextBox4").value = DataTables("劳动报酬").compute("Count([单位])","评定等级 = 'C'")
Forms("劳动报酬").Controls("TextBox5").value = DataTables("劳动报酬").compute("Count([单位])","评定等级 = 'D'")
End If
End Select
'百分比
Dim zc As Integer = CInt(Forms("劳动报酬").Controls("TextBox1").Text) '在册
Dim a As Integer = CInt(Forms("劳动报酬").Controls("TextBox2").Text) 'A
Dim b As Integer = CInt(Forms("劳动报酬").Controls("TextBox3").Text) 'B
Dim c As Integer = CInt(Forms("劳动报酬").Controls("TextBox4").Text) 'C
Dim d As Integer = CInt(Forms("劳动报酬").Controls("TextBox5").Text) 'D
Dim ab As Double = IIf(a=0,0,a/zc*100)
Dim bb As Double = IIf(b=0,0,b/zc*100)
Dim cb As Double = IIf(c=0,0,c/zc*100)
Dim db As Double = IIf(d=0,0,d/zc*100)
Forms("劳动报酬").Controls("TextBox6").Value = ab
Forms("劳动报酬").Controls("TextBox6").Value = Math.Round(ab,2)
Forms("劳动报酬").Controls("TextBox7").Value = bb
Forms("劳动报酬").Controls("TextBox7").Value = Math.Round(bb,2)
Forms("劳动报酬").Controls("TextBox8").Value = cb
Forms("劳动报酬").Controls("TextBox8").Value = Math.Round(cb,2)
Forms("劳动报酬").Controls("TextBox9").Value = db
Forms("劳动报酬").Controls("TextBox9").Value = Math.Round(db,2)
出错如图:
此主题相关图片如下:i.png
[此贴子已经被作者于2011-10-13 13:47:41编辑过]