• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 511
  • Last Modified:

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

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
JA67
Asked:
JA67
  • 2
  • 2
1 Solution
 
Rey Obrero (Capricorn1)Commented:
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
 
Rey Obrero (Capricorn1)Commented:
or
cdbl(left(me.textname,5)&"."&mid(me.textname,6))
0
 
JA67Author Commented:
Thank you!  That works great! I am going to store the this as a number.
0
 
JA67Author Commented:
I have received excellent help from capricorn1 on many occassions!
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now