RP1America
Technical User
I am in the process of creating a userform. A textbox on the form is used for a percentage. The textbox is initialized as "%".
The following code results in the textbox being able to be exited in percentage format, as well as if they blank out the textbox or take no action prior to exiting the textbox, it returns to "%".
What I need is to know how to define within the case if the user gives the textbox a value, say "4.05%", then exits the textbox...then for whatever reason reenters and reexits without changing anything. Therefore "4.05%" is not currently defined within my case. Is it possible to do this with some sort of numeric variable (e.g. "#.##%")? If so, how would it be displayed?
Thanks for the help!!
The following code results in the textbox being able to be exited in percentage format, as well as if they blank out the textbox or take no action prior to exiting the textbox, it returns to "%".
What I need is to know how to define within the case if the user gives the textbox a value, say "4.05%", then exits the textbox...then for whatever reason reenters and reexits without changing anything. Therefore "4.05%" is not currently defined within my case. Is it possible to do this with some sort of numeric variable (e.g. "#.##%")? If so, how would it be displayed?
Thanks for the help!!
Code:
Private Sub UserForm_Initialize()
txtRT11.Value = "%"
End Sub
Private Sub txtRT11_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Select Case txtRT11
Case ""
txtRT11 = "%"
Case "%"
txtRT11 = "%"
Case Else
txtRT11.Text = Format(txtRT11 * 0.01, "percent")
End Select
End Sub