+ Reply to Thread
Results 1 to 8 of 8

Add Property to UserForm via class module - please help

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,946

    Add Property to UserForm via class module - please help

    Hi,

    I have problem writing class module and connect it to my Userform (in attachment my macro)

    My userform is called "FormyAnulacji" and i want to add to them one more property:

    FormyAnulacji.Rows = it will be LastRowStatement.

    Class Module:

    Please Login or Register  to view this content.
    For example my property Rows = 10.

    So i want to set this property like this in module:

    FormyAnulacji.Rows = 10

    and next FormyAnulacji.show

    and inside my userform i should have this property which i can set up once again in userform.

    Or maybe I can do it directly in userform (not use module?)

    So goal:
    Write additional property to my userform in order to use it inside all buttons and listbox within userform.

    Please help,
    Best Regards,
    Jacek Antek
    Attached Files Attached Files
    Last edited by jaryszek; 08-18-2016 at 07:16 AM.

  2. #2
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,946

    Re: Add Property to UserForm via class module - please help

    Hi,

    i have found sometginh like that:

    http://dailydoseofexcel.com/archives...to-a-userform/

    "Properties

    Because a userform is just a class module with a built-in user interface, you can create properties in the form’s module. The form’s module might look like this"

    Please Login or Register  to view this content.
    I dont understand it - maybe anyone can help?

    Best regards,
    Jacek Antek

  3. #3
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,946

    Re: Add Property to UserForm via class module - please help

    Hi Guys,

    I am Guru - I solved the problem which is simple.

    First of all you have to declare additional property to your userform (inside userform - in the beginning):

    Please Login or Register  to view this content.
    So Wiersz_Gl it is ma additional property to userform.

    In my userform it is simple (when combobox for example change - you can put it wherever you want)

    Please Login or Register  to view this content.
    So this will first go through Let property like this (you are set the variable for Wiersz_Gl userform property):

    Let.jpg

    And next you supposably want to get this property in commandbutton (or listbox, or textbox - wherever you want) in the same userform:

    Please Login or Register  to view this content.
    your code will get the variable from your defined property:

    get.jpg

    It is simple !

    I hope that my struggle with this will be useful for somebody.

    One thing is important here, one question - is this method quicker than reference to Function procedura? Getting class of the object? Maybe you know that.

    Warm Regards,
    Jacek Antek
    Last edited by jaryszek; 08-19-2016 at 03:16 AM.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Add Property to UserForm via class module - please help

    Jacek

    What are you going to do with this property?
    If posting code please use code tags, see here.

  5. #5
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,946

    Re: Add Property to UserForm via class module - please help

    I wanted to have number of rows in all my buttons, listboxes, texboxes (everywhere in my userform) to get row what i wanted in rowsource Table, that is all.

    Jacek Antek

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,646

    Re: Add Property to UserForm via class module - please help

    Jacek

    Can't you get that using the existing ListCount property of the controls?

  7. #7
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,946

    Re: Add Property to UserForm via class module - please help

    Norie

    I am using "A_Wniosek.Range("A1").CurrentRegion.Rows.Count" and thnaks to it i have number of rows in For Example Combobox. But i wanted to have this also in others Userform objects and in order to have this variable i added property to my userform.

    Now in quick way i can pulled out this variable whenever i want.

    Best regards,
    Jacek Antek

  8. #8
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,946

    Re: Add Property to UserForm via class module - please help

    Hi Guys,

    Is another problem here.

    I have issue like here:

    http://stackoverflow.com/questions/1...vents-the-same

    Problem is that i cant set global variable.
    Because i have several modules.

    So i can do public variable to my userform, next i can pass this variable to Sub in other module.
    And in this sub i want to change my variable from false to true and pass back to my userform.

    How can i do it ? the best i think will be the class where i can set global variable and change it.

    What do you think ?

    Jacek

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [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
  2. [SOLVED] Userform & Dynamic Controls & Class Module
    By sarndt01 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 09-18-2014, 01:53 PM
  3. Replies: 0
    Last Post: 03-08-2014, 08:02 AM
  4. Replies: 1
    Last Post: 10-12-2012, 04:36 AM
  5. [SOLVED] Userform Match - unable to get the match property of the worksheetfunction class - Help!
    By Tayque_J_Holmes in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-10-2012, 11:01 AM
  6. [SOLVED] ComboBox class .AddItem filled in class module
    By Jacques Grobler in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-03-2012, 05:48 AM
  7. Replies: 1
    Last Post: 08-30-2011, 02:23 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