Results 1 to 3 of 3

Thread: VB Objects and Modules

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2000
    Posts
    2

    Unhappy

    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

  2. #2
    Hyperactive Member
    Join Date
    Dec 1999
    Posts
    321
    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.
    Signed, Rodik ([email protected])
    Programmer,usesVB6ED
    ===========================
    Copyright©RodikCo,2002.

    Dont mind this signature ;] Its old

  3. #3
    Fanatic Member RealisticGraphics's Avatar
    Join Date
    Jul 1999
    Location
    Arkansas
    Posts
    655

    Thumbs up

    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.
    www.RealisticGraphics.net

    Running VS.Net Enterprise & VB 6

    Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML

    MSN Messenger: kmsheff

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width