Hi,
I'm storing values typed into a datagrid in an Excel spreadsheet, but if I type a non integer number in the datagrid, when it gets stored in Excel, a load more decimal places get added to which it just seems to add random numbers to.
The value in the datagrid is 0.17 - that column in the datagrid has some formatting on it:
If I check the value of the Excel cell while in debug mode, the immediate windows shows this:
?wks.Cells(byteSheet_Row_Count, 12).value
0.17000000178813934 {Double}
Double: 0.17000000178813934 {Double}
Now the 1st few values that are below 1 it messes up, but after that the rest of the numers are integers which don't get "adjusted"
I guess I could store the datagrid value in a string before passing it to Excel, but I want to know why Excel (or VB) is doing this.
Thanks
Kristian
I'm storing values typed into a datagrid in an Excel spreadsheet, but if I type a non integer number in the datagrid, when it gets stored in Excel, a load more decimal places get added to which it just seems to add random numbers to.
Code:
wks.Cells(byteSheet_Row_Count, 12).value = datagridDilution.Rows.Item(byteData_Grid_Row_Count).Cells(0).Value
Code:
datagridDilution.Columns(0).ValueType = GetType(Single)
datagridDilution.Columns(0).DefaultCellStyle.Format = "n2"
?wks.Cells(byteSheet_Row_Count, 12).value
0.17000000178813934 {Double}
Double: 0.17000000178813934 {Double}
Now the 1st few values that are below 1 it messes up, but after that the rest of the numers are integers which don't get "adjusted"
I guess I could store the datagrid value in a string before passing it to Excel, but I want to know why Excel (or VB) is doing this.
Thanks
Kristian