Your Favourite API or VBA Class Module Example

  • Hook Mouse wheel to scroll Userform Frame


    Found this to be a handy addition to allow scrolling in userform frames or other controls


    module code





    Userform code

  • auto alpha numeration of a userform checkbox list



    clsFrmCtls class


    Code
    1. Option Explicit
    2. Public mName
    3. Public mFrm As Object
    4. Public Event SelectedChange(objCtr)
    5. Public WithEvents mCheckBox As MSForms.CheckBox
    6. Private Sub mCheckBox_Click()
    7. RaiseEvent mFrm.SelectedChange(mName)
    8. End Sub
  • RadioButton Grades


    Class module called RadioCount


    userform module code


    Just add more OptionButtons with yes or no Captions to the userform and the code will adjust the grade accordingly

  • Class for Textbox entry limited to Numeric or Alphanumeric entry


    Userform Code





    Class module clsFrmTboxText



    Class module clsFrmTboxNumber

  • Hello Pike ...:wink:


    As usual .. extremely handy codes ...!!! :smile:


    You are building a Generic Library which is becoming THE Reference ....:congrats:


    Cheers

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Like" icon ...just below...in the bottom right corner...:)

  • Enhanced "Popup menu at mouse position" is one I have been using a lot.
    Instead of returning the additem id number it returns the popup text associated wit the id number.
    It uses a event with in the clsPopup class to populate a external collection to return the text.


    In the clsPopup class add dimensions

    Code
    1. Public Event AddCollection(objStr, objInd) ' add this line
    2. Public Frm As Object ' add this line


    and in the additem function

    Code
    1. RaiseEvent Frm.AddCollection(varItem, CStr(nID))


    In the userform add dimension

    Code
    1. Dim mylist As Collection


    and event to populate the collection

    Code
    1. Public Sub AddCollection(varItem, nID)
    2. mylist.Add varItem, nID
    3. End Sub


    Then the result is retrieved like

    Code
    1. lngResult = mnu.PopUpMnu
    2. If Not lngResult = 9 And Not lngResult = 0 Then
    3. MsgBox "You picked " & mylist(CStr(lngResult))
    4. End If



    Its easier to follow in the complete syntax in the attached workbook

  • '''''' normal module code I tried changing the calls as suggested in the link for 64-bit (compilation error,, automation error, excel crash , but with less expertise i am not able to get it work ....

    Anyone in thyis forum is having migrated calls for 64-bit office working, please share

    '''''''' end normal module code