Solved

In VBA, add a decimal after the 5th digit of a number.

Posted on 2007-11-29
4
451 Views
Last Modified: 2013-11-28
I have a number, like this, "394154616203704" and I need to place a decimal after the 5th digit, like this: 39415.4616203704
There can be a varying amount of digits after the decimal.   I need to do this in VBA to a number that is in a text box.

I have been playing with the Format function but can't seem to get it right. I greatly appreciate your help.

Thank you!
JA67

Open in new window

0
Comment
Question by:JA67
  • 2
  • 2
4 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 20374786
try  using the left and mid function, do you have to save this as number or text

left("394154616203704",5)&"."&mid("394154616203704",6)

or
left(me.textname,5)&"."&mid(me.textname,6)
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 20374877
or
cdbl(left(me.textname,5)&"."&mid(me.textname,6))
0
 

Author Comment

by:JA67
ID: 20374992
Thank you!  That works great! I am going to store the this as a number.
0
 

Author Closing Comment

by:JA67
ID: 31411700
I have received excellent help from capricorn1 on many occassions!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now