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

    Option Explicit
    Public mName
    Public mFrm As Object
    Public Event SelectedChange(objCtr)
    Public WithEvents mCheckBox As MSForms.CheckBox
    Private Sub mCheckBox_Click()
        RaiseEvent mFrm.SelectedChange(mName)
    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:


    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Smiley" icon, 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

    Public Event AddCollection(objStr, objInd) ' add this line
    Public Frm As Object ' add this line

    and in the additem function

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

    In the userform add dimension

    Dim mylist As Collection

    and event to populate the collection

    Public Sub AddCollection(varItem, nID)
        mylist.Add varItem, nID
    End Sub

    Then the result is retrieved like

    lngResult = mnu.PopUpMnu
        If Not lngResult = 9 And Not lngResult = 0 Then
           MsgBox "You picked " & mylist(CStr(lngResult))
        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

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!