Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27184

Declaring variables

$
0
0
Hello!

I have been having trouble saving a button as a variable;
Code:

        Private Button1 As Button
        Public ReadOnly btn As Button = Button1
        Public Overridable Property Goal As Integer
        Public ReadOnly Value As Integer = Button1.BackColor.A

        Sub New(ByVal button_ As Button, ByVal goal As Integer)
            Me.Goal = goal
            Button1 = button_
        End Sub

The error is given at line 4, where a method calls the button. After some inspection I realised, that the "Button1" variable was always nothing, no matter wich button I put in the New sub. Does anyone know what could be done?

Regards,
CrazyVB

Viewing all articles
Browse latest Browse all 27184

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>