stripping out decimal places

esposj

New member
Local time
Today, 11:06
Joined
Jun 22, 2001
Messages
6
Hi,
I'm outputting an asci report to be imported by a seperate accounting package. For numbers I need the format to look like this
dddddddddcc(+-)
where d is dollars, c is cents, and it is followed by a plus or a minus (no parens).

I am using the format command and have everything working except the stripping of the decimal place. Any ideas?

btw. Great resource here!!!

Joe Esposito
Seagroatt Floral Wholesalers
Albany, NY
 
Joe,

How about something like this;

Private Function strfn_Value( _
ByVal curValue As Currency) _
As String

Dim strSign As String * 1
Dim curValue_Abs As Currency

curValue_Abs = Abs(curValue)
strSign = IIf(curValue_Abs - curValue, "-", "+")
strfn_Value = curValue_Abs * 100 & strSign

End Function

Jon
 
that worked great! Good idea..

if you wouldn't mind explaining one thing for me...

Dim strSign As String * 1
what is the * 1 for?

Thanks,
Joe
 
Joe,

The * 1 after the string declaration specifies that the string can only have one character. It wasn't necessary to declare it this way, it just makes it more explicit to someone reading the code. Strings initialised this way will always be that length, regardless of whether a value is ever assigned to them.

Jon
 
Thanks again.. I have been doing a lot of research the last couple of days, and must say that this VBA stuff is a lot more fun then my normal job of unix c programming
smile.gif


btw this is kind of wierd. My roomate's name is John Holmes - odd.

Joe
 
I did this same thing. Run an update query to multiply your currency by 100. This will change
402.23 to 40223.00 when you export it will drop the .00 leaving you with 40223

Thanks
Kim
 
Kim,
I must admit, that I feel pretty dumb for not realizing this myself
smile.gif


Who thinks about math when coding
smile.gif


Joe
 

Users who are viewing this thread

Back
Top Bottom