|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
CDec("")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)) 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: Show quoteHide quote > 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)) cj wrote:
> I thought, apparently incorrectly, CDec("") would result in 0D. That will fail too since the IIf function will evaluate the CDec(...)> > 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)) 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 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: Show quoteHide quote > 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 > "cj" <cj@nospam.nospam> schrieb: Check out 'Decimal.TryParse'.>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)) -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
can a method implement an interface and handle an event at the same time?
Using ByteArrays Key Required for .Update with mdb file ? Assuming True tracing a line in a bitmap? Printing from webbrowser control... Size of an Object eidt registry entry within .NET application Image Editing designing login form with complete focus problem in msgbox - reg |
|||||||||||||||||||||||