Solved

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

Posted on 2007-11-29
4
487 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) 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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

687 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