Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 23rd, 2005, 11:07 AM
Registered User
Join Date: Nov 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to pass value between class module?

Option Explicit
I know that i can write the value into a cell, but is there another mean to achieve this?

[u]Environnement class module:</u>

Public mlG As Double

Public Property Get G() As Double
G = mlG
End Property

Private Sub Class_Initialize()
mlG = 9.81
End Sub

[u]boule class module</u>
Option Explicit

Dim mlHauteur As Double
Dim mlVitesse As Double

Public Property Get Hauteur() As Double
Hauteur = mlHauteur
End Property

Public Property Let Hauteur(ByVal h As Double)
mlHauteur = h
End Property

Public Property Get Vitesse() As Double
Vitesse = Sqr(2 * mlG * mlHauteur) 'computes the speed
End Property
Private Sub Class_Initialize()
mlHauteur = 10
End Sub

[u]and the procedure for testing these 2 class:</u>

Sub testBoule()
Dim objBoule As boule
Dim objEnv As Environnement

Set objBoule = New boule
    Set objEnv = New Environnement
    With objBoule
    MsgBox " speed of boule on the floor = " _
    & .Vitesse

    End With
End Sub

now the boule object cannot read the mlG variable declared in the environnement class module, what's the solution?
thanks in advance

Old November 23rd, 2005, 12:58 PM
Friend of Wrox
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post

Hi yvon,

How you pass the value really depends on what you are doing, one way to achieve it would be to pass it in when you make the method call e.g.
MsgBox " speed of boule on the floor = " & .GetVitesse(objEnv.G)
Function GetVitesse(g As Double) As Double
    GetVitesse = Sqr(2 * g * mlHauteur)
End Function


Similar Threads
Thread Thread Starter Forum Replies Last Post
Pass contents of drop down list to helper class snejsnej ASP.NET 1.0 and 1.1 Basics 0 April 12th, 2006 04:06 PM
how to pass values between class modules ? yvon Beginning VB 6 1 December 7th, 2005 05:13 PM
Class module variables in VB6 maxpotters Pro VB 6 2 September 18th, 2005 12:15 PM
Missing code in the FormChanger class module jkuusik BOOK: Excel 2003 VBA Programmer's Reference 0 April 20th, 2005 08:55 AM
CFormChanger Class module maccas Excel VBA 0 September 28th, 2004 07:36 AM

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