简体   繁体   中英

MS Excel vba number formatting

Is it possible to set a format to a UserForm textbox so that it automatically changes the numbers from 123456789.123456789 to 123,456,789.123456789.

Private Sub TextBox1_Change()
TextBox1.Value = Format(TextBox1.Value, "#,###.##")
End Sub

I used this, but it round the number to 123,456,789.12 .

Is 123,456,789.123456789 possible within the VBA ? Thanks.

You can add as many # as you want to specify the number of figures after the dot. In your case you can use a format

Format(TextBox1.Value, "#,###.#########")

Should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM