Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 178
  • Last Modified:

A Question

In my project , I have three class A , B , C .

In class A
{
      Dim b as new B
}

And In class C , I want to manage variable b  . How can I do that ?
0
clbit-org
Asked:
clbit-org
  • 4
1 Solution
 
kalyan258Commented:
use public b as new B

Hope you can access it from class C - if u create an instance for A.
0
 
kalyan258Commented:
Check this code:

Imports System.Diagnostics

Public Class B
    Public b As Integer = 3
    Public Sub test()
        Debug.WriteLine("Hi from B : " + b.ToString())
    End Sub
End Class

Public Class A
    Public b As New b
    Public Sub test1()
        Debug.WriteLine("Hi from A")
    End Sub
End Class

Public Class c
    Sub tester()
        Dim c As New A
        c.test1()
        c.b.test()
        c.b.b = 4
        Debug.WriteLine(c.b.b.ToString())
    End Sub
End Class

Module Module1

    Sub Main()
        Dim c As New c
        c.tester()
    End Sub

End Module
0
 
kalyan258Commented:
output is

Hi from A
Hi from B : 3
4

does this help solve your query.

Check this from with IDE as debug.writeline will not produce output in command window - it will produce results in output window in the bottom.

Cheers...
0
 
beryl666Commented:
class A = super class
class C = sub class
0
 
kalyan258Commented:
super class and subclass relationship exists only if we have inherited the class C from class A - but here we just have only an instance of the class A in class C. Please refer http://www.howtodothings.com/viewarticle.aspx?article=414
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now