473,326 Members | 2,175 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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
Nov 20 '06 #1
5 4071
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

Nov 20 '06 #2
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" <du******@gmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.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

Nov 20 '06 #3
No in general I guess I can't use like it is a double. Need to use:

55 - d.value

thanks

" Franky" <fr**********@a-znet.comwrote in message
news:uo**************@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" <du******@gmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.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


Nov 20 '06 #4
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

Nov 20 '06 #5
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
"Chris Dunaway" <du******@gmail.comwrote in message
news:11**********************@j44g2000cwa.googlegr oups.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

Nov 20 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Duke Hamacher | last post by:
Hello: This title is a little ambiguous but this is an interesting puzzle. Lets's say we have a JSP page with a form. The ActionForm associated with this form has, say, 4 String properities. ...
21
by: Alex Martelli | last post by:
I hesitate a bit to post this, but... on the Italian Python NG, somebody was asking whether there was any way to convert an integer number x into a string which represents it in an arbitrary base N...
13
by: gary | last post by:
Hi, We all know the below codes are dangerous: { int *p = new int; delete p; delete p; } And we also know the compilers do not delete p if p==NULL. So why compilers do not "p = NULL"...
2
by: Robin Tucker | last post by:
(note, this is a C# or VB.NET ambivalent question....) Hi, Have a slight problem with a library I'm using here (which I have the source code for). It has data files serialized with an...
3
by: moi | last post by:
Hello, When user write a decimal number in a textbox with the numeric pad, he hits the "." button but in FRANCE, we use the ",". How to change the "." in the textbox with a "," ? Example : user...
9
by: axs221 | last post by:
I am trying to move some of our large VBA Access front-end file into ActiveX DLL files. I created two DLL files so far, one was a module that contains code to integrate into the QuickBooks...
6
jasjas
by: jasjas | last post by:
my Q is like this, i want to design a calculation which use the number user enter to "/" by 100. so , offcouse the result mayb in double or integer. after that my calculation just wanna user...
2
by: mktselvan | last post by:
Hi, Existing running oracle application 11i (11.5.8) Database version is 8.1.7.4 There is any command / way to know the number of concurrent users for this application. ...
10
by: nspader | last post by:
I want to start out saying I am a novice code writer. I am trying to send a report via email based on each supplier. The code below is what I am using. I need to base recordset on Form, report...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.