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.
kbraju76Asked:
Who is Participating?
 
Joe_GriffithCommented:
Or pass it to the second sub as an argument:

Public Class Form1
    Inherits System.Windows.Forms.Form

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

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

End Class
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.