Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 437
  • Last Modified:

vba word number formatting a textbox

Hi again experts,

Another quick question, i'm trying to find a way to format a few userform textbox's but no luck its for formatting it incorrect.

this is the code:

Private Sub txtvjhjp_AfterUpdate()

txtvjhjp.Text = Format(txtvjhjp.Value, "#.##0,00")

End Sub

Open in new window


The result is this: 7000,0000
when it should be this: 7.000,00

I'm also looking for a way to do it easier, there is a few textboxes that need this format is there an easier way, like simply right the textbox name on a list and it will put the form in them all, something like this:

Private Sub decimalseparator_AfterUpdate()

Format(value, "#.##0,00")
    .txtvjhjp
    .txtvjhp
    .txtabc
End Sub

Open in new window


no clue if this is possible at all but would make it easier and the code would be more clean i guess :)

thank you in advance
0
Hakum
Asked:
Hakum
  • 3
  • 2
  • 2
  • +1
1 Solution
 
Rgonzo1971Commented:
Hi,

Maybe

"#,##0.00"

it will normally automatically onvert to the right separators

Regards
0
 
HakumAuthor Commented:
that worked like a charm!! awesome thank you!,

 but how about a code for more textboxes using this format?
0
 
Rgonzo1971Commented:
No easy way that I can think of
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
IrogSintaCommented:
You can just select all the textboxes together (using the Ctrl key) then just insert the following in the FORMAT property:
#,##0.00

Ron
0
 
aikimarkCommented:
You have to make a translation when coding formats in countries where the decimal symbol is a comma and the thousands separator is a period.
0
 
HakumAuthor Commented:
IrogSinta - I can't seem to fin that propety, is that in the propeties window?
0
 
IrogSintaCommented:
It's the topmost property in the Format tab of the Property Sheet. If you put #,##0.00 in there it will automatically change to Standard

property sheet
0
 
HakumAuthor Commented:
Sadly i think this function is only available in access or so, im try to code this in word vba so its not there.

But thanks!

Capture.PNG
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

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