Simple question - integers

H

HardySpicer

I need to pass an integer value to another class. I define the integer
as

Public spb as integer
spb=10

(and it changes to other values)

and it passes to other subs within the main class ok but not into
other classes...why? I tries

Public shared but no difference.

Thanks

J.
 
F

Family Tree Mike

HardySpicer said:
I need to pass an integer value to another class. I define the integer
as

Public spb as integer
spb=10

(and it changes to other values)

and it passes to other subs within the main class ok but not into
other classes...why? I tries

Public shared but no difference.

Thanks

J.


See if this example gets you started:

Class Foo
Public Shared bar As Integer = 3
Public baz As Integer = 4
End Class
Module Module1

Sub Main()

Console.Out.WriteLine(Foo.bar) ' shared field use
Console.Out.WriteLine((New Foo).baz) ' instance field use
Console.In.ReadLine()

End Sub

End Module
 
H

HardySpicer

See if this example gets you started:

Class Foo
    Public Shared bar As Integer = 3
    Public baz As Integer = 4
End Class
Module Module1

    Sub Main()

        Console.Out.WriteLine(Foo.bar)  ' shared field use
        Console.Out.WriteLine((New Foo).baz) ' instance field use
        Console.In.ReadLine()

    End Sub

End Module

So I should call it Form1.spb

I remember now!

thanks
 
R

rowe_newsgroups

So I should call it Form1.spb

I remember now!

thanks

Personally, I think using static (shared) variables is a bad idea. I
would prefer to hand the integer to the method that requires it,
instead of tightly coupling the other classes to your Form.

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top