In addition to Garth's suggestion, don't just use
Dim
and hope the system will sort it out - it can't infer from the
Value
property what type
deg
should be. Specify exactly what type you are expecting, and it'll start to work.
Dim deg1 = gridSelectMusician.Rows(0).Cells(0).Value
Debug.WriteLine(deg1.ToString("000"))
Debug.WriteLine(deg1.ToString("0.00"))
Will give you this:
1
1
Because
deg1
is an
Object
so it uses
Object.ToString
Dim deg2 As Double = gridSelectMusician.Rows(0).Cells(0).Value
Debug.WriteLine(deg2.ToString("000"))
Debug.WriteLine(deg2.ToString("0.00"))
Will give you a better result:
001
1.23
Because it can use the
Double.ToString
override that accepts a format parameter.
It's generally a damn good idea to always specify your types - letting the system sort it out can cause all sorts of problems! (And is just one of the reasons VB is often seen as a childish language)