Results 1 to 15 of 15

Code to format number input in textbox controls (based on tag) in userform

Threaded View

asha3010 Code to format number input... 07-02-2010, 05:36 AM
royUK Re: Code to format number... 07-02-2010, 05:37 AM
royUK Re: Code to format number... 07-02-2010, 05:49 AM
asha3010 Re: Code to format number... 07-02-2010, 05:50 AM
royUK Re: Code to format number... 07-02-2010, 05:52 AM
asha3010 Re: Code to format number... 07-02-2010, 06:19 AM
asha3010 Re: Code to format number... 07-03-2010, 07:41 AM
snb Re: Code to format number... 07-03-2010, 10:24 AM
asha3010 Re: Code to format number... 07-03-2010, 12:09 PM
royUK Re: Code to format number... 07-03-2010, 02:14 PM
royUK Re: Code to format number... 07-03-2010, 02:47 PM
asha3010 Re: Code to format number... 07-05-2010, 04:17 AM
royUK Re: Code to format number... 07-05-2010, 06:46 AM
asha3010 Re: Code to format number... 07-05-2010, 01:08 PM
royUK Re: Code to format number... 07-05-2010, 01:09 PM
  1. #1
    Forum Contributor
    Join Date
    02-09-2010
    Location
    Constanta
    MS-Off Ver
    Excel 2007
    Posts
    128

    Code to format number input in textbox controls (based on tag) in userform

    Greetings,

    I have started creating a userform with several textbox controls. The input in these textbox controls should be displayed either in the "Percent" or "Standard" format. Instead of having a code for each textbox control, I used the tag property "P" & "S" and put together this code:

    Private Sub UserForm1_Initialize()
        Dim oCtrl As MSForms.control
        For Each oCtrl In Me.Controls
            If oCtrl.Tag = "P" Then
                oCtrl.Value = Format((oCtrl.Value) / 100, "Percent")
                If oCtrl.Tag = "S" Then
                    oCtrl.Value = Format(oCtrl.Value, "Standard")
                End If
            End If
        Next oCtrl
    End Sub
    But when I enter a number in the textbox control, the display does not change.

    Can someone please tell me what is wrong?

    Many thanks
    Asha
    Last edited by asha3010; 07-05-2010 at 04:18 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1