Reputation: 1
I want to convert string of exponent values (values are stored in data grid view continuously) to string of decimal values
For Each waveform As AnalogWaveform(Of T) In waveforms
scaledDataGridView.Rows(rowIndex).Cells(columnIndex).Value = scaledRecords(columnIndex - 1)(rowIndex - lastCount).ToString("E")
columnIndex += 1
Next
If rowIndex Mod 100 = 0 Then
Application.DoEvents()
End If
Next
Threading.Thread.Sleep(500)
TextBox1.Text = scaledDataGridView.Rows(rowIndex).Cells(columnIndex).Value.ToString("D")
Upvotes: 0
Views: 222
Reputation: 7465
I'd change this to:
TextBox1.Text = scaledDataGridView.Rows(rowIndex).Cells(columnIndex).Value.ToString("D")
To
Dim dec as Double = Convert.ToDouble(scaledDataGridView.Rows(rowIndex).Cells(columnIndex).Value)
TextBox1.Text = dec.ToString("G17")
The reason is because you need to convert back to a number before any formatting could be done. In your case, it's trying to format a string with a format of D.
This will work up to about 17 places, otherwise it's different.
More info here: https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings#GFormatString
Upvotes: 0