Results 1 to 10 of 30

Thread: Class related Stuff Userforms

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    10,457
    Rep Power
    10
    ......”........... Continued from last post..............”......


    ¬_2c) Why can this catch one out, (why am I posting this “warning” )

    I expect many people will just take the UserForm they see as a “thing” and use it by its name, whether the default, such as UserForm1 , ( UserForm2 if they create a second User Form “thing” ) or the name they give it.
    I tried to access properties through the name of the “thing” I see in the VB Editor, which was actually the Class name, as it is always is.
    My Code kindly given to me by someone was more “correctly” ( IMO ) written so as not to rely on Implicit defaults, so I had something like this

    10 Dim fm1 As UserForm1
    20 Set fm1 = New UserForm1


    Subsequently code line such as
    Let UserForm1.CheckBox1.Value = True
    or in particular what was causing me problems
    If UserForm1.CheckBox1.Value = True Then
    Did not error as the first one of those used had creating a second new instance of Class UserForm1. But I was wanting to reference the first instance, fm1, as this was used further in the code for all dealings with the actual instance of the UserForm that I was interested in.

    Hope that helps anyone else Puzzled that any code line similar to this is not giving the correct results

    UserForm1.Property
    or
    myUserFormName.Property =

    _................................................. ..............


    _3) The solution / answer again to the main Question


    _3a) Question.
    UserForm.____ not working

    _3b) Answer
    If you have not yourself written the existing code, then check if your instancing of the actual userForm you are interested in has been done Explicitly, rather than left to the Implicit Default, which you are ( maybe unknowingly ) assuming

    Alan


    Edit P.s. Tell someone you are giving such a code : “I declared Explicitly the Userform, so bear that in mind if you attempt to access any of its Properties in code modifications – I did not leave it to the Implicit default of the UserForm Class name”. ( Not that would of made any difference to me – I would of just thought – “what load of old B llox is he making up now” .. Lol.. )
    Rem Ref
    http://www.excelforum.com/showthread...t=#post4383895
    Rem Ref http://www.excelforum.com/showthread...t=#post4381274
    Rem Ref http://www.excelforum.com/showthread...t=#post4381275
    Rem Ref http://www.excelforum.com/showthread...t=#post4381420
    Last edited by DocAElstein; 06-01-2024 at 07:53 PM.

Similar Threads

  1. Class Stuff: VBA Custom Classes & Objects, Class Modules
    By DocAElstein in forum Excel and VBA Tips and Tricks
    Replies: 29
    Last Post: 06-02-2024, 01:49 PM
  2. Replies: 42
    Last Post: 05-29-2023, 01:19 PM
  3. Test my rights , to do stuff
    By TestAccount in forum Test Area
    Replies: 0
    Last Post: 10-07-2020, 11:49 AM
  4. Backup all modules, class modules and userforms to a selectable folder
    By MrBlackd in forum Excel and VBA Tips and Tricks
    Replies: 1
    Last Post: 04-06-2014, 08:33 AM
  5. Pass Values Between Multiple Userforms
    By Excel Fox in forum Excel and VBA Tips and Tricks
    Replies: 0
    Last Post: 07-24-2011, 03:25 AM

Posting Permissions

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