Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Storing the Variable value in vb.net

Posted on 2004-10-25
2
Medium Priority
?
203 Views
Last Modified: 2010-05-18
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.
0
Comment
Question by:kbraju76
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 12401956
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
 
LVL 7

Accepted Solution

by:
Joe_Griffith earned 500 total points
ID: 12402462
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

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question