userform & textboxes

B

beginner

hi!
i've made an userform which has several textboxes. i need
to give to the textboxes some format.
for example:
textbox1 has to be currency format
textbox2 has to be date format
textbox3 has to be percent format
how can i do this?
tia.
 
B

Bob Phillips

Private Sub TextBox1_AfterUpdate()
With Me.TextBox1
.Value = Format(.Value, "$#,##0.00")
End With
End Sub

Private Sub TextBox2_AfterUpdate()
With Me.TextBox2
.Value = Format(.Value, "dd-mmm-yyyy")
End With
End Sub

Private Sub TextBox3_AfterUpdate()
With Me.TextBox3
.Value = Format(.Value, "0%")
End With
End Sub



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
B

beginner

hi mr. phillips.

i found in excels' vba help the next tip:

valor = Application.WorksheetFunction.VLookup(numero,
serv, 79, false)
frmResultado.txt1.Value = FormatCurrency(valor, 2)

it works but i've had some troubles when the cell's format
doesn't match with the FormatXXXXX function. (XXXXX =
Currency, Number,TimeDate, Percent)

any suggestion?

tia.
 
B

Bob Phillips

That is when you could use the custom formats as I suggested.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Top