473,395 Members | 1,571 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,395 software developers and data experts.

CDec("")

cj
I thought, apparently incorrectly, CDec("") would result in 0D.

Unless someone here can tell me something better it seems in reading my
report file I'll have to say something like

amount = IIf(line.Substring(20, 11).Trim = Nothing, 0D,
CDec(line.Substring(20, 11)))

instead of

amount = CDec(line.Substring(20, 11))
Sep 15 '06 #1
4 4110
cj
Ooops, just rudely reminded that iif evaluates both cases before using
one so that gives errors too so I guess it'll be an old fashioned if
else statement.

cj wrote:
I thought, apparently incorrectly, CDec("") would result in 0D.

Unless someone here can tell me something better it seems in reading my
report file I'll have to say something like

amount = IIf(line.Substring(20, 11).Trim = Nothing, 0D,
CDec(line.Substring(20, 11)))

instead of

amount = CDec(line.Substring(20, 11))
Sep 15 '06 #2
cj wrote:
I thought, apparently incorrectly, CDec("") would result in 0D.

Unless someone here can tell me something better it seems in reading my
report file I'll have to say something like

amount = IIf(line.Substring(20, 11).Trim = Nothing, 0D,
CDec(line.Substring(20, 11)))

instead of

amount = CDec(line.Substring(20, 11))
That will fail too since the IIf function will evaluate the CDec(...)
part even if it is empty. You need to use this instead:

strAmt = line.Substring(20,11).Trim()
If strAmt <String.Empty Then
amount = CDec(strAmt)
Else
amount = 0D
End If

Sep 15 '06 #3
cj
Yea IIf doesn't help, as you probably noted in my email just moments
before you replied was again reminded of that.

Due to some testing lines in the report some of my otherwise fields that
should be blank or a number come up like "0 0" so I went with

If IsNumeric(tempString) Then amount = CDec(tempString) Else amount = 0D

Chris Dunaway wrote:
cj wrote:
>I thought, apparently incorrectly, CDec("") would result in 0D.

Unless someone here can tell me something better it seems in reading my
report file I'll have to say something like

amount = IIf(line.Substring(20, 11).Trim = Nothing, 0D,
CDec(line.Substring(20, 11)))

instead of

amount = CDec(line.Substring(20, 11))

That will fail too since the IIf function will evaluate the CDec(...)
part even if it is empty. You need to use this instead:

strAmt = line.Substring(20,11).Trim()
If strAmt <String.Empty Then
amount = CDec(strAmt)
Else
amount = 0D
End If
Sep 15 '06 #4
"cj" <cj@nospam.nospamschrieb:
>I thought, apparently incorrectly, CDec("") would result in 0D.

Unless someone here can tell me something better it seems in reading my
report file I'll have to say something like

amount = IIf(line.Substring(20, 11).Trim = Nothing, 0D,
CDec(line.Substring(20, 11)))

instead of

amount = CDec(line.Substring(20, 11))
Check out 'Decimal.TryParse'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Sep 15 '06 #5

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

Similar topics

9
by: Bernie Yaeger | last post by:
I'm trying to control the textbox keypress event to deal with a "." such that it disallows a second "." and no characters after 2 numbers beyond the "." (thus a currency value). I have no problem...
2
by: Michael MacDonald | last post by:
I have written a simple program that calculates a running $ total. This program uses a checkbox to acknowledge that that version of the ticket is desired and it checks the Qty box to see how many...
11
by: Bruce Lawrence | last post by:
Ok, I'm baffled... I'm making a query in access 97 between 2 tables. There is a field in both tables called "DWGNO". OPENORD has a record with a DWGNO of "00000012345" DIEDATA has a record...
0
by: Just_a_fan | last post by:
Some folks have searched, from time to time, for a dual axis MSChart with different scales on the two Y axes. The sample, extracted from running code I wrote, produces a graph with MSChart (VB9)...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.