PDA

View Full Version : AfterUpdate Event



fiza
04-02-2010, 03:26 AM
Hi Anyone,

I'm using the following code to get the value as g/dl in my userform. I want the number to appear 1.0g/dl after I press the tab button. Suppose I write 2 in the txtbox, I want the number to be 2.0g/dl and if I write 2.1 it to be 2.1g/dl and so on.

Private Sub txtweight_AfterUpdate()
If IsNumeric(txttxtweight.Value) Then
txtRecipientHaemoglobin.Value = txtweight.Value + " g/dl"
End If
End Sub
Any help would be kindly appreciated.

Regards
Fiza

Bob Phillips
04-02-2010, 03:32 AM
Private Sub txtweight_AfterUpdate()

If IsNumeric(txttxtweight.Value) Then

txtRecipientHaemoglobin.Value = Format(txtweight.Value, "0.0") & " g/dl"
End If
End Sub

fiza
04-02-2010, 03:49 AM
Thanks for the help. Your modification works fine.

fiza
04-02-2010, 04:12 AM
By the way if I want to write the number format in 777-7777 in the text field txtContactNo how could the code be modified?

Any help would be greatly appreciated

Bob Phillips
04-02-2010, 05:17 AM
With Me.txtContactNo

.Text = Format(.Text, "000-0000")
End With

fiza
04-02-2010, 05:30 AM
Once again, Thanks for the help. this modification also does what I wanted.