i give a example:
y1=380-val(grid.cell(j,1))*uv has a wrong result (uv and y1 are double,j is byte)
y1=380-(val(grid.cell(j,1))*uv) has the good result
With a string variable at the place of grid.cell(j,1) the result is good in the first case
bug with stringgrid ?
bug with stringgrid ?
Did some tests in a little program:
dim uv as double
dim y1 as double
dim j as byte
dim grid as Stringgrid
j = 1
grid.Cell(1,1)="10"
uv=2
y1=380-val("10")*uv `380 - 10 * 2
showmessage Str$(y1) ` 360 <- ok
y1=380 - val(grid.cell(j,1)) * uv ` 380 - 10 * 2
showmessage Str$(y1) ` 740 <- wrong result, is evaluated as (380 - 10) * 2
y1=(380-val(grid.cell(j,1)))*uv ` (380 - 10) * 2
showmessage Str$(y1) ` 740 <- ok
y1=380-(val(grid.cell(j,1))*uv) ` 380 - (10 * 2)
showmessage Str$(y1) ` 360 <- ok
I don`t think the grid has a bug but the expression is not properly evaluated and has the bug.
Perhaps thats the reason i always use () so i don`t have to think i which order an expression is being evaluated.
dim uv as double
dim y1 as double
dim j as byte
dim grid as Stringgrid
j = 1
grid.Cell(1,1)="10"
uv=2
y1=380-val("10")*uv `380 - 10 * 2
showmessage Str$(y1) ` 360 <- ok
y1=380 - val(grid.cell(j,1)) * uv ` 380 - 10 * 2
showmessage Str$(y1) ` 740 <- wrong result, is evaluated as (380 - 10) * 2
y1=(380-val(grid.cell(j,1)))*uv ` (380 - 10) * 2
showmessage Str$(y1) ` 740 <- ok
y1=380-(val(grid.cell(j,1))*uv) ` 380 - (10 * 2)
showmessage Str$(y1) ` 360 <- ok
I don`t think the grid has a bug but the expression is not properly evaluated and has the bug.
Perhaps thats the reason i always use () so i don`t have to think i which order an expression is being evaluated.