|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Can a Decimal variable be set to "Not a Number"Can a Decimal variable be set to "Not a Number"
I've been looking in the help and can't find any reference to that. Thanks in advance Franky wrote:
> Can a Decimal variable be set to "Not a Number" I don't think so, but you can declare a variable of Nullable(Of> Decimal) and set it Nothing: Dim d As Nullable(Of Decimal) d = Nothing Then in code you can check if it is assigned a value: If d.HasValue Then 'Do Something End If This only works with .Net 2.0 Thanks. If I understand the Help I if x is Decimal I can use d as if it is
Decimal Dim d As Nullable(Of Decimal) .... If d.HasValue Then x=d End If Thanks again Show quoteHide quote "Chris Dunaway" <dunaw***@gmail.com> wrote in message news:1164030723.516423.25260@b28g2000cwb.googlegroups.com... > Franky wrote: >> Can a Decimal variable be set to "Not a Number" >> > > I don't think so, but you can declare a variable of Nullable(Of > Decimal) and set it Nothing: > > Dim d As Nullable(Of Decimal) > > d = Nothing > > > Then in code you can check if it is assigned a value: > > If d.HasValue Then > 'Do Something > End If > > This only works with .Net 2.0 > No in general I guess I can't use like it is a double. Need to use:
55 - d.value thanks Show quoteHide quote " Franky" <frankyNOSPAM@a-znet.com> wrote in message news:uoC0Q3KDHHA.2176@TK2MSFTNGP04.phx.gbl... > Thanks. If I understand the Help I if x is Decimal I can use d as if it is > Decimal > > Dim d As Nullable(Of Decimal) > > ... > > If d.HasValue Then > x=d > End If > > > Thanks again > > > "Chris Dunaway" <dunaw***@gmail.com> wrote in message > news:1164030723.516423.25260@b28g2000cwb.googlegroups.com... >> Franky wrote: >>> Can a Decimal variable be set to "Not a Number" >>> >> >> I don't think so, but you can declare a variable of Nullable(Of >> Decimal) and set it Nothing: >> >> Dim d As Nullable(Of Decimal) >> >> d = Nothing >> >> >> Then in code you can check if it is assigned a value: >> >> If d.HasValue Then >> 'Do Something >> End If >> >> This only works with .Net 2.0 >> > > Franky wrote:
> No in general I guess I can't use like it is a double. Need to use: That's because it is a Decimal and not a double. If you need a double,> then use double instead of decimal: Dim d As Nullable(Of Double) d = 14.56 Dim d2 As Double If d.HasValue Then d2 = d.Value * 3 Else d2 = 0.0 End If Chris I meant to say Decimal not Double.
I meant, I can't simply add to d, I must add to d.value It's too bad they didn't take the max value and use that as NaN and decrease the max available by 1. I could get by with the max a little smaller =====================I meant to say No in general I guess I can't use like it is a decimal. Need to use: 55 - d.value rather than 55-d ================================== But I see you set d = 14.56 not d.Value = 14.56 How come you can do that? thanks again Show quoteHide quote "Chris Dunaway" <dunaw***@gmail.com> wrote in message news:1164039730.716843.151240@j44g2000cwa.googlegroups.com... > Franky wrote: >> No in general I guess I can't use like it is a double. Need to use: >> > > That's because it is a Decimal and not a double. If you need a double, > then use double instead of decimal: > > Dim d As Nullable(Of Double) > > d = 14.56 > > Dim d2 As Double > > If d.HasValue Then > d2 = d.Value * 3 > Else > d2 = 0.0 > End If > > Chris >
naming conventions forced by VS.NET?
Attribute instantiation How to declare a sub class thread dead lock Passing multiple arguments to the client-side JavaScript function in AJAX Replace " character in string DataGridView1 (VS2005) Multi line grid row with .net compact framework 2.0 Search string in textfile Name space referencing problem |
|||||||||||||||||||||||