Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Beginning VB 6
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 23rd, 2005, 11:09 AM
Registered User
Join Date: Nov 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to pass values between class modules ?

other than by writing values in excel sheet? (i am talking about VBA in excel).
thank you.

Reply With Quote
  #2 (permalink)  
Old December 7th, 2005, 05:13 PM
Friend of Wrox
Join Date: Nov 2004
Location: Port Orchard, WA, USA.
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts

First of all, there is no such concept as passing values between class modules. Class modules are (essentially) templates used for creating instances of the class described within them.
These instantiations of classes (called objects) have values, but the modules that describe how these instances should be created do not.
In the class module, create an exposed variable of the type of the other class that this class must work with.
     Public TheOther As clsTheOther
Create a method to do your manipulating.
Public Sub MakeChange()
    TheOther.ItsProperty = Me.MyProperty
End Sub
Then make an instance of both classes, set the public variable of the class I've shown the code of here to be a reference to the object that needs to be changed, then call the method.
  . . .
    Dim objWorker As New clsWorker
    Dim objWorked As New clsRecipient

    ' Set a reference. (There are now 2 references to the same object.)
    Set objWorker.TheOther = objWorked 

    objWorker.MakeChange              ' Do the work

    Set objWorker.TheOther = Nothing  ' Release the reference

  . . .
objWorked will now have the value that you set it up to receive, having come from the value you set up to send in objWorker.
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Class modules lallemantdo Excel VBA 4 August 24th, 2005 08:35 PM
What is Meant by Instancing in Class Modules ramk_1978 VB Components 1 February 2nd, 2005 12:09 AM
how to pass multiple values throw url class object kfarooq Servlets 1 June 20th, 2003 04:06 AM
Class Modules ezzedin Beginning VB 6 2 June 9th, 2003 03:04 AM

All times are GMT -4. The time now is 01:07 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.