Newbie ByRef Sub question
Posted on 2003-11-13
Form1.vb launches a custom dialog box form, Age.vb, to say ask for the users age:
frmAge = New Age(UserAge)
MsgBox("Hey you are: " & UserAge)
In Age.vb we have:
Public Sub New(ByRef UsersAge As Integer)
a TextBox1 where they enter their age and a Button_OK to exit the dialog
When the user presses the OK button I can validate the entry they put in the TextBox1 but I do not know how to get the entry from TextBox1 to pass back when the user presses OK because the variable "UsersAge" is local to the Sub "New" only.
How do I make it global so I can change it and pass it back?
If I try the following in the event handler for Button_OK.Click :
UsersAge = CInt(TextBox1.Text)
I of course get a: Name 'UsersAge' is not declared , complaint from the IDE.