Solved

VB.Net: Resuable code doubt

Posted on 2012-03-31
3
165 Views
Last Modified: 2012-03-31
Hi, i am using vb.net

I use to declare some variables. And i declare them again and again in many methods.

For example

dim strName as string
dim strNumber as Number
dim active as Boolean
.
.
.many more

What i am asking is, now it is possible to invoke a single method from multiple classes. Like wise is it possible to keep these variables declared on a single location and the use them in other methods and classes, so that i dont have to retype the variable declarations again and again on each and every method or class.

Hope my question was clear.

Thanks in advance
0
Comment
Question by:baabaa_nl
[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
3 Comments
 
LVL 30

Expert Comment

by:IanTh
ID: 37790880
so are you using them as a global variable or a local variable in the function

you have not made that clear
0
 

Author Comment

by:baabaa_nl
ID: 37790972
well, it is a local variable in the function
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 37790993
Either:
(1) Declare them as Public in a Module.

(2) Make them Shared variables:
Public Class Form1
    Public Shared strName As String
End Class

Open in new window

Then you can use Form1.strName from anywhere

(3) Create a Class to hold the values and pass that around.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

726 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