Results 1 to 10 of 30

Thread: Class related Stuff Userforms

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #7
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    10,457
    Rep Power
    10
    https://www.excelforum.com/excel-pro...ml#post4382748
    https://www.excelfox.com/forum/showt...ll=1#post24173







    Hallo !
    Thanks for the replies


    Quote Originally Posted by rorya View Post
    You need to be referring to fm.OptionButton2 not ufResults.OptionButton.....


    So I tried
    v = fm.OptionButton2.Value
    instead in the Worksheet_change Code

    It works !!! – gives True or False appropriately !
    Thanks!!


    Here goes the Nut rambling again, sorry about that..
    Clearly I have not a clue about user Forms and sadly running out of time to learn.
    All I see is in the VB Project Window is ufResults, so I thought that “is” the UserForm ??
    That tied up with what Richard suggested. He suggested
    UserForm1.
    Now... if I insert a new Userform, it gets the name
    UserForm1.
    The one you did for me has this name
    ufResults.
    So clearly There seems some logic to what I tried to do?
    And the lines with that in do not error, ( just always give False )

    _..........................
    Quote Originally Posted by rorya View Post
    If you need access to these from other routines, you should move the declaration of fm appropriately.


    Sorry i do not ( did not ) get it as usual, I guess it means to do with to get the last Three lines to work in this code in a normal module, may be ?
    Code:
    Sub CheckOptionCheckCheckedCheck()
    Dim v As Variant
    Let v = ufResults.StatusBarNormal.Value 'Always gives False
    Let v = ufResults.OptionButton2.Value 'Always gives False
    Let v = ufResults.Refresh.Value 'Always gives False
    'Let v = fm.StatusBarNormal.Value 'At attempt to run code error with complie "error variable not defined"
    'Let v = fm.OptionButton2.Value
    'Let v = fm.Refresh.Value
    End Sub

    I spent some considerable time being very precise about referring to Ranges correctly but clearly I have no idea what / where the parallel is with User Forms...

    So, can I ask
    _ What is fm ?
    And
    _ What is ufResults?
    _ How come I can access ( I mean it does not error in those lines above ) ufResults from elsewhere,
    but not fm from other than where it is...

    Or is this parallel to Code Modules, like this: If I Declared it in a normal module, then would I be able to access it elsewhere. – ( Sorry with this one I hesitate to experiment. – I do not want to create UserForms all over the place hap hazadly !!)*****

    In my VB Project Window ufResults does not seem to be tied down to a Sheet. And , again, I cannot find this “thing” fm anywhere! What is fm!!!

    Or how about.
    ufResults is a sort of class thing, and fm is one instance of it. *****


    Alan

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

    *****Edit: OKI I did anyway experiment
    Just to balance out a bit...
    I did this .... I “kloned”
    _- got two with things showing
    Code:
        If fm Is Nothing Then Set fm = New ufResults
        If Not fm.Visible Then fm.Show False 'make sure UserForm is always there,
    Static fm2 As ufResults
        If fm2 Is Nothing Then Set fm2 = New ufResults
        If Not fm2.Visible Then fm2.Show False
    May be I do get it... a bit,
    I did this, and the second code does not work...
    Code:
    Sub MakeAInstanceOfufResults()
    Static fm2 As ufResults
        If fm2 Is Nothing Then Set fm2 = New ufResults
        If Not fm2.Visible Then fm2.Show False
    Dim v As Variant
    Let v = fm2.StatusBarNormal.Value 'At attempt to run code error with complie "error variable not defined"
    Let v = fm2.OptionButton2.Value
    Let v = fm2.Refresh.Value
    End Sub
    Sub CheckOptionCheckCheckedCheckOffm2()
    Dim v As Variant
    'Let v = fm2.StatusBarNormal.Value 'At attempt to run code error with complie "error variable not defined"
    'Let v = fm2.OptionButton2.Value
    'Let v = fm2.Refresh.Value
    End Sub
    _............................

    But now I do this in a normal Module:
    Code:
    Public fm2 As ufResults
    Public fm As ufResults
    (_....And this in my Worksheet:Change code..
    Code:
    'Static fm As ufResults
    _.......)
    and all is well
    All the following work , that is to say give the results I expect.

    Code:
    Option Explicit
                'Public RefreshCColumn As Boolean 'For Check box to recalculate all values  ' I do not need this now as i think the Nut has User Forms sussed...
    Public fm2 As ufResults
    Public fm As ufResults
    Sub MakeAInstanceOfufResults()
        If fm2 Is Nothing Then Set fm2 = New ufResults
        If Not fm2.Visible Then fm2.Show False
    Dim v As Variant
    Let v = fm2.StatusBarNormal.Value
    Let v = fm2.OptionButton2.Value
    Let v = fm2.Refresh.Value
    End Sub
    Sub CheckOptionCheckCheckedCheckOffm2()
    Dim v As Variant
    Let v = fm2.StatusBarNormal.Value
    Let v = fm2.OptionButton2.Value
    Let v = fm2.Refresh.Value
    End Sub
    Sub CheckOptionCheckCheckedCheckOffm()
    Dim v As Variant
    Let v = fm.StatusBarNormal.Value
    Let v = fm.OptionButton2.Value
    Let v = fm.Refresh.Value
    End Sub
    There, you see, preparing concisely in a Thread Reply can help you sometimes get there yourself...

    I Thanks us, you and me
    Alan
    Last edited by DocAElstein; 06-01-2024 at 06:12 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
  •