Results 1 to 3 of 3

Place code in userform, module or class module

Threaded View

  1. #1
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Place code in userform, module or class module

    In the attached workbook is an attempt to enforce formatting to certain textbox entries in a multipage userform. The reason for this class module approach is that this is the groundwork to apply to a much larger application when sorted.

    I have control of the formatting of the textboxes I require by way of choosing to set a array in the class module.

    On multipage1 first and last textbox has no entry restriction - 2 and 3 are set to a date format "dd mm yyyy"

    I wanted to add an exit event that requires the text length to be a minimum 10 digits

    In the bottom right corner I have a test textbox that behaves as I wish it to by way of

    Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
            With TextBox1
            If TextBox1.Text = "" Then Exit Sub
                If Len(TextBox1.Text) < 10 Then
                    .Tag = ""
                    .SelStart = 0
                    .SelLength = Len(.Text)
                    MsgBox "Please Enter Date in dd mm yyyy format"
                Cancel = True
                Else: Exit Sub
                End If
            End With
    End Sub
    I would like to have this format for all the textboxes declared in the array but it is failing me as to where to place or how to code it. I have tried replacing
    TextBox1
    with
    NumericTextBox
    as I have used elsewhere but to no avail. Any pointers appreciated
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Add Property to UserForm via class module - please help
    By jaryszek in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-07-2016, 09:35 AM
  2. [SOLVED] Userform ComboBox Class Module not working
    By rodgersmg in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-24-2016, 03:23 AM
  3. [SOLVED] Userform & Dynamic Controls & Class Module
    By sarndt01 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 09-18-2014, 01:53 PM
  4. Replies: 0
    Last Post: 03-08-2014, 08:02 AM
  5. Replies: 1
    Last Post: 10-12-2012, 04:36 AM
  6. Replies: 1
    Last Post: 08-30-2011, 02:23 AM
  7. how to access Sheet module, normal module, Worbook module to type code
    By alibaba in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-31-2009, 07:51 AM

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