-
Can anyone please help!
I am making a program with mutiple forms in which all have similar procedures eg play stop whatever.
I have also created a class module in which I have detailed the code for these events, but when I call this code in the specific for it doesn't work because in the code the objects such as lblsong, lblartist, although common throughout the forms will not work. Also variables I have made in the module when I call in the particular form do not work.
What do I have to do to make the variables and objects work in all forms when they have the same names.
The subs are all public subs too
Thanks
-
Hm... dunno really what your problem is...
but it seems your not creating a new object so use an ordinary module and Public the variables in the Declaration of that module too.
-
Hmmm... He's right, you should probably use a module instead of the class. But if I'm understanding you correctly you are having trouble retrieving values from form controls in the module. Here is a quick example of using forms and modules.
Form1 (Add a textbox and 2 buttons)
Form1:
Code:
Private Sub Command1_Click()
ShowMeTheMoney(text1.text)
End Sub
Private Sub Command2_Click()
WhatIsYourFavoriteColor
End Sub
Module1:
Code:
Function ShowMeTheMoney(txt As String) As String
ShowMeTheMoney = FormatCurrency(txt, 2, vbFalse, vbFalse, vbFalse)
End Function
Public Sub WhatIsYourFavoriteColor()
MsgBox Form1.Text1.Text
End Sub
Try it out, study it, pull what you need.