View Full Version : Percent format in a textbox giving odd results
philfer
06-26-2014, 08:41 AM
Hello,
I have a textbox on a form formatted as percent to 5dp.
If the user enters 0.6 it enters it as 0.60000% if the user enters .6 it enters it as 60.00000%
Whats up with that???
Cheers
No idea but Excel does the same thing.
Seems to depend on whether or not the percent sign is displayed when it saves the value.
typing
0.6 = 0.60000%
.6% = 0.60000%
.6 = 60.00000%
0.6 and delete the % = 60.00000%
Maybe it uses the % to determine whether to convert the value and it only automatically inserts the % sign if the first character entered is numeric.
I suppose you could check the value before the update and then fix it.
Dim PC As String
Private Sub textbox0_BeforeUpdate(Cancel As Integer)
PC = textbox0.Text
End Sub
Private Sub textbox0_AfterUpdate()
If PC = "" Then Exit Sub
If Right(PC, 1) <> "%" Then
textbox0 = PC & "%"
End If
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.