SEPERATING INTEGER AND DECIMALS FROM A

# Thread: SEPERATING INTEGER AND DECIMALS FROM A

1. Amaresh Guest

## SEPERATING INTEGER AND DECIMALS FROM A

I want to seperate Integer and Decimals from a whole number<BR>Eg.<BR>Whole Number -&#062; 12345.67 to be seperated to<BR>Integer -&#062; 12345<BR>decimal -&#062; 67<BR><BR>I tried ot out giving<BR>(WholeNumber - (Int(WholeNumber)))<BR>for decimals<BR><BR>But I am ending up with some exponential results some times<BR>

2. Jas
Member
Join Date
Dec 1969
Posts
45

## RE: SEPERATING INTEGER AND DECIMALS FROM

Try this:<BR>strWN=cstr(wholenumber)<BR>intWhere=instr (strWN,".")<BR>if intWhere &#062; 0 then<BR> strIntPart=left(strWN,intWhere -1)<BR> strDecPArt=right(strWn,len(strWN)-intWhere)<BR> lngIntPart=clng(strIntPart)<BR> lngDecPArt=clng(strDecPart)<BR>else<BR> lngIntPart=clng(strWN)<BR> lngDecPArt=0<BR>end if<BR><BR><BR>

3. Senior Member
Join Date
Dec 1969
Posts
96,118

## RE: SEPERATING INTEGER AND DECIMALS FROM

But those exponential results are the right ones!<BR><BR>That is, if you do<BR>123.00052<BR>then the fractional (decimal) part is 0.00052 but by default VBS will display that number, no matter how obtained, with exponential notation.<BR><BR>So if you want it to "look pretty", you can simply use the FormatNumber function to ask for as many decimal places as you think you need.<BR><BR>

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•