Link to home
Start Free TrialLog in
Avatar of kbraju76
kbraju76

asked on

Storing the Variable value in vb.net

Hi expert,

 In the PreRender Sub, iam getting one value(example: date) then I assigned to some variable .  While I try to use the date in the another Sub , nothing is there in the variable.
How can I get the variable value from one sub to another Sub.

Your help is much appreciated.

Regards,
Raju.
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Declare a variable at the class level to hold the value so it can be accessed from any function/sub within the class:

Public Class Form1
    Inherits System.Windows.Forms.Form

    Private someDate As Date

    Private Sub firstSub(ByVal d As Date)
        someDate = d
    End Sub

    Private Sub secondSub()
        ' do something with somedate
        MsgBox(someDate)
    End Sub

End Class
ASKER CERTIFIED SOLUTION
Avatar of Joe_Griffith
Joe_Griffith

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial