I want to set a variable during the page load event then use it on the click event. Where do I declare the variable?
Printable View
I want to set a variable during the page load event then use it on the click event. Where do I declare the variable?
At Class Level.
Code:Public Class Form1
Inherits System.Windows.Forms.Form
Region " Windows Form Designer generated code "
Dim test As String
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
test = "Testing"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
MsgBox(test)
End Sub
End Class
thanks