troubleshooting Question

Programming a VB6 dll (trying to understand class variables)

Avatar of HKComputer
HKComputerFlag for United States of America asked on
Visual Basic Classic
9 Comments1 Solution360 ViewsLast Modified:
I'm trying to program some of my own message box functions and put them in a dll to be used by my other VBScript and VB .exe projects. The first one I am trying to make is a Message Box that can take up to five arguments. The first one will be the message box title. The other 4 will be the caption for each button. The dll function will pass back the caption of the button that was clicked by the user.

So what kind of variables do I need and how do I pass them to the form when I open the form? And how do I pass the value of the clicked button back to the user?

Here's the code I have but it doesn't compile. My class module is named cMsgBoxes. I don't know where to go from here:

Option Explicit

Public strTitle As Variant
Public strcmd1 As Variant
Public strcmd2 As Variant
Public strcmd3 As Variant
Public strcmd4 As Variant
Public strMsgBox As Variant

Public Property Let Title(strTitle As String)
    Title = strTitle
End Property

Public Property Let Command1(strcmd1 As String)
    Command1 = strcmd1
End Property

Public Property Let Command2(strcmd2 As String)
    Command2 = strcmd2
End Property
Public Property Let Command3(strcmd3 As String)
    Command3 = strcmd3
End Property
Public Property Let Command4(strcmd4 As String)
    Command4 = strcmd4
End Property


Function MsgBox4Button(strTitle As String, strcmd1 As String, Optional strcmd2 As String, Optional strcmd3 As String, Optional strcmd4 As String)
   
    Load frmMsgBox4Button
    MsgBox4Button = strMsgBox
   
End Property






My Form Code:

Option Explicit


Private Sub cmd1_Click()
    cMsgBoxes.strMsgBox = Me.cmd1.Caption
    Unload Me.Name
End Sub

Private Sub cmd2_Click()
    cMsgBoxes.strMsgBox = Me.cmd2.Caption
    Unload Me.Name
End Sub

Private Sub cmd3_Click()
    cMsgBoxes.strMsgBox = Me.cmd3.Caption
    Unload Me.Name
End Sub

Private Sub cmd4_Click()
    cMsgBoxes.strMsgBox = Me.cmd4.Caption
    Unload Me.Name
End Sub

Private Sub Form_Load()
   
    Me.Caption = strTitle
    Me.cmd1.Caption = Trim(strcmd1)
    Me.cmd2.Caption = Trim(strcmd2)
    Me.cmd3.Caption = Trim(strcmd3)
    Me.cmd4.Caption = Trim(strcmd4)
   
    If Nz(Me.cmd1.Caption, "") = "" Then
        Me.cmd1.Visible = False
        Unload Me.Name
    End If
   
    If Nz(Me.cmd2.Caption, "") = "" Then Me.cmd2.Visible = False
    If Nz(Me.cmd3.Caption, "") = "" Then Me.cmd3.Visible = False
    If Nz(Me.cmd4.Caption, "") = "" Then Me.cmd4.Visible = False
   
       
End Sub

Private Function Nz(strValue As Variant, strChangeTo As String) As String
    If Not IsNull(strChangeTo) Then
        If strValue = Null Then strValue = strChangeTo
    End If
End Function
ASKER CERTIFIED SOLUTION
Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 9 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 9 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004