I met a strange scene in my code. I succeed to call out the number i want from the database. But when I sum it up, the amount is incorrect. Even i had pop up messagebox before it do the calculation. And the number shown is correct. The only thing is when the hour add to the value in flexgrid, the answer is wrong. Please Help me. I think of it so long time but still can't get it.
Thanks a lot...
Data in the server is:
Texture 1
AW 0.5
LZT 0.5
PC 1
Texture 1
LZT 1.25
The answer that I get from the below code is:
lzt hr 1.25
lztgrid 0
tolzt1.25
tex hr1
texgrid 0
totaltex 1
totex1
pc hr1
pcgrid 0
toPC2
lzt hr0.5
lztgrid 1.25
tolzt1.5
aw hr0.5
awgrid 0
toaw1.5
tex hr1
texgrid1
totaltex2
totex2
Thanks a lot...
Data in the server is:
Texture 1
AW 0.5
LZT 0.5
PC 1
Texture 1
LZT 1.25
The answer that I get from the below code is:
lzt hr 1.25
lztgrid 0
tolzt1.25
tex hr1
texgrid 0
totaltex 1
totex1
pc hr1
pcgrid 0
toPC2
lzt hr0.5
lztgrid 1.25
tolzt1.5
aw hr0.5
awgrid 0
toaw1.5
tex hr1
texgrid1
totaltex2
totex2
Code:
Private Function sunday() AdoSun.RecordSource = "select *from downtime where Date = '" + txtSun.Text + "' " AdoSun.Refresh Datagrid.Refresh If (DGSun.ApproxCount <> 0) Then 'if row count is not 0 then calculate the total hour AdoSun.Recordset.MoveLast Do While (AdoSun.Recordset.BOF <> True) If (AdoSun.Recordset.Fields("Process")) = "Texture" Then MsgBox "tex hr" & AdoSun.Recordset.Fields("Hour") MsgBox "texgrid " & MSHFlexGrid1.TextMatrix(1, 1) MsgBox "totaltex " & Val(MSHFlexGrid1.TextMatrix(1, 1) + Val(AdoSun.Recordset.Fields("Hour"))) MSHFlexGrid1.TextMatrix(1, 1) = MSHFlexGrid1.TextMatrix(1, 1) + Val(AdoSun.Recordset.Fields("Hour")) MsgBox "totex" & MSHFlexGrid1.TextMatrix(1, 1) End If If (AdoSun.Recordset.Fields("Process")) = "Acid Wash" Then MsgBox "aw hr" & AdoSun.Recordset.Fields("Hour") MsgBox "awgrid " & MSHFlexGrid1.TextMatrix(2, 1) MSHFlexGrid1.TextMatrix(2, 1) = MSHFlexGrid1.TextMatrix(1, 1) + Val(AdoSun.Recordset.Fields("Hour")) MsgBox "toaw" & MSHFlexGrid1.TextMatrix(2, 1) End If If (AdoSun.Recordset.Fields("Process")) = "LZT" Then MsgBox "lzt hr" & AdoSun.Recordset.Fields("Hour") MsgBox "lztgrid " & MSHFlexGrid1.TextMatrix(3, 1) MSHFlexGrid1.TextMatrix(3, 1) = MSHFlexGrid1.TextMatrix(1, 1) + Val(AdoSun.Recordset.Fields("Hour")) MsgBox "tolzt" & MSHFlexGrid1.TextMatrix(3, 1) End If If (AdoSun.Recordset.Fields("Process")) = "PC" Then MsgBox "pc hr" & AdoSun.Recordset.Fields("Hour") MsgBox "pcgrid " & MSHFlexGrid1.TextMatrix(4, 1) MSHFlexGrid1.TextMatrix(4, 1) = MSHFlexGrid1.TextMatrix(1, 1) + Val(AdoSun.Recordset.Fields("Hour")) MsgBox "toPC" & MSHFlexGrid1.TextMatrix(4, 1) End If AdoSun.Recordset.MovePrevious Loop Else End If End Function