Consulting

Results 1 to 6 of 6

Thread: AfterUpdate Event

  1. #1

    AfterUpdate Event

    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,445
    Location
    [vba]
    Private Sub txtweight_AfterUpdate()

    If IsNumeric(txttxtweight.Value) Then

    txtRecipientHaemoglobin.Value = Format(txtweight.Value, "0.0") & " g/dl"
    End If
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Thanks for the help. Your modification works fine.

  4. #4
    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

  5. #5
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,445
    Location
    [vba]

    With Me.txtContactNo

    .Text = Format(.Text, "000-0000")
    End With
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  6. #6
    Once again, Thanks for the help. this modification also does what I wanted.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •