View Full Version : Solved: Textbox Format Value
jammer6_9
05-01-2007, 11:21 PM
How can I display the textbox value in "%" format?
.TextBox1.Value = c.Offset(0, 28).Value
Simon Lloyd
05-02-2007, 02:33 AM
I believe it's something like this used in the Sub tetxbox1_change:
Me.TextBox1.Value = Format(Textbox1.Value, "%")
where Me will be the object it resides in, if you are using it in code not in the object module you need to specify the object i.e Userform1.TextBox1.....etc
Regards
Simon
mdmackillop
05-02-2007, 05:39 AM
To change 15 to 15.00%
Me.TextBox1.Value = Format(TextBox1.Value / 100, "0.00%")
Simon Lloyd
05-02-2007, 06:03 AM
LOL i was close!
jammer6_9
05-02-2007, 07:41 AM
Save data in the worksheet using TextBox1 (Perfect Code). Thanks "mdmackillop" for this code. It makes the user entry more easier.
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Me.TextBox1.Value = Format(TextBox1.Value / 100, "0.0%")
End Sub
But when I call back the data in the worksheet using TextBox1, 10% becomes 0.1 in the textbox happens when I used below code.
Call data from the worksheet using TextBox1
.TextBox1.Value = c.Offset(0, 28).Value
mdmackillop
05-02-2007, 08:35 AM
.TextBox1.Value = Format(c.Offset(0, 28).Value ,"0.0%)
jammer6_9
05-02-2007, 02:35 PM
:bow: mdmackillop :bow: Perfect. Thanks
.TextBox1.Value = Format(c.Offset(0, 28).Value ,"0.0%)
What about passing a null value with this code...
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Me.TextBox1.Value = Format(TextBox1.Value / 100, "0.0%")
End Sub
Bob Phillips
05-02-2007, 07:50 PM
Use the text property .TextBox1.Value = c.Offset(0, 28).Text
jammer6_9
05-03-2007, 12:18 AM
I have this code in the textbox. When I skip the textbox1 error come which is data type mismatch that made me into conclusion that skipping the textbox1 is not permitted. What I want to happen is a code if it's possible to skip textbox1 and entry to be made in textbox2.
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Me.TextBox1.Value = Format(TextBox1.Value / 100, "0.0%")
End Sub
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Me.TextBox2.Value = Format(TextBox2.Value / 100, "0.0%")
End Sub
Bob Phillips
05-03-2007, 04:03 AM
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
With Me.TextBox1
If .Value = "" Then
.Value = 0
End If
.Value = Format(.Value / 100, "0.0%")
End With
End Sub
jammer6_9
05-04-2007, 01:23 AM
xld :cool: ... this code works perfectly... once again thanks.
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
With Me.TextBox1
If .Value = "" Then
.Value = 0
End If
.Value = Format(.Value / 100, "0.0%")
End With
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.