Solved

Setting up global variable in asp.net vb.net.

Posted on 2007-03-26
2
2,804 Views
Last Modified: 2012-06-21
How should I setup the following global variables in asp.net 2.0.

'Variables servant a referrer la Division (ainsi que la BD associee a cette division)
    Dim strActiveDivision
    Dim strActiveDivisionName
    Dim strActiveGenericName
    Dim strActiveIHDBName
    Dim strActiveIHServerName
    Dim strActiveIHConnection
    Dim strActiveMADBName
    Dim strActiveMAServerName
    Dim strActiveMAConnection
    Dim strActiveMWDBName
    Dim strActiveMWServerName
    Dim strActiveMWConnection
    Dim strActiveAWDBName
    Dim strActiveAWServerName
    Dim strActiveAWConnection
    Dim strActiveReport2WebName

    Dim DivisionLevel, ClassLevel, SubDeptLevel, DeptLevel, RegionLevel, ClassLength, SubDeptLength, DeptLength
    Dim SubClassLevel, SubClassLength, OnHandAvailable, OnHandInTransit
    Dim mstrYearPeriod
Where should the above global variables go. I am trying to transform this application from asp classic
to asp.net.

    Public GetDivisionValuesinArrary()

    strTmp  = Request.Form("selDivision")
    ' The division here needed to be populated with the appropriate value.
    ' The dropdownlist box has two values ddlDivisions in the dropdownbox

      arrTmp = Split(strTmp,";")
      If IsArray(arrTmp) then
            strActiveDivision = arrTmp(0)
            strActiveDivisionName = arrTmp(1)
            strActiveGenericName = arrTmp(2)
            strActiveIHServerName = arrTmp(3)
            strActiveIHDBName = arrTmp(4)
            strActiveAWServerName = arrTmp(5)
            strActiveAWDBName = arrTmp(6)            
            strActiveMAServerName = arrTmp(7)
            strActiveMADBName = arrTmp(8)
            strActiveMWServerName = arrTmp(9)
            strActiveMWDBName = arrTmp(10)
            strActiveReport2WebName = arrTmp(11)                                                      
            DivisionLevel = arrTmp(12)      
            DeptLevel = arrTmp(13)      
            SubDeptLevel = arrTmp(14)      
            ClassLevel = arrTmp(15)                  
            DeptLength = arrTmp(16)      
            SubDeptLength = arrTmp(17)      
            ClassLength = arrTmp(18)                  
            OnhandAvailable = arrTmp(19)      
            OnhandInTransit = arrTmp(20)      

      end if

      mstrYearPeriod = txtMonthTo.Txt ''''Get value from text box

End Sub



This will need to be a class that should be called in many apps.

I must setup the subroutine to return an array as well.
0
Comment
Question by:mathieu_cupryk
[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 15

Accepted Solution

by:
crisco96 earned 500 total points
ID: 18798807
Put the variables in a new class and declare them public.  You can then declare a new instance of the class and then access the variables.

Option Strict On
Option Explicit On

Public Class Globals
      Public strActiveDivision As String
      Public strActiveDivisionName As String
      Public strActiveGenericName As String
      Public strActiveIHDBName As String
      Public strActiveIHServerName As String
      Public strActiveIHConnection As String
      Public strActiveMADBName As String
      Public strActiveMAServerName As String
      Public strActiveMAConnection As String
      Public strActiveMWDBName As String
      Public strActiveMWServerName As String
      Public strActiveMWConnection As String
      Public strActiveAWDBName As String
      Public strActiveAWServerName As String
      Public strActiveAWConnection As String
      Public strActiveReport2WebName As String
      Public DivisionLevel As String
      Public ClassLevel As String
      Public SubDeptLevel As String
      Public DeptLevel As String
      Public RegionLevel As String
      Public ClassLength As String
      Public SubDeptLength As String
      Public DeptLength As String
      Public SubClassLevel As String
      Public SubClassLength As String
      Public OnHandAvailable As String
      Public OnHandInTransit As String
      Public mstrYearPeriod As String

      Public Sub New()
            Dim strTmp As String = System.Web.HttpContext.Current.Request.Form("selDivision")
            ' The division here needed to be populated with the appropriate value.
            ' The dropdownlist box has two values ddlDivisions in the dropdownbox

            Dim arrTmp() As String = Split(strTmp, ";")

            If IsArray(arrTmp) Then
                  strActiveDivision = arrTmp(0)
                  strActiveDivisionName = arrTmp(1)
                  strActiveGenericName = arrTmp(2)
                  strActiveIHServerName = arrTmp(3)
                  strActiveIHDBName = arrTmp(4)
                  strActiveAWServerName = arrTmp(5)
                  strActiveAWDBName = arrTmp(6)
                  strActiveMAServerName = arrTmp(7)
                  strActiveMADBName = arrTmp(8)
                  strActiveMWServerName = arrTmp(9)
                  strActiveMWDBName = arrTmp(10)
                  strActiveReport2WebName = arrTmp(11)
                  DivisionLevel = arrTmp(12)
                  DeptLevel = arrTmp(13)
                  SubDeptLevel = arrTmp(14)
                  ClassLevel = arrTmp(15)
                  DeptLength = arrTmp(16)
                  SubDeptLength = arrTmp(17)
                  ClassLength = arrTmp(18)
                  OnHandAvailable = arrTmp(19)
                  OnHandInTransit = arrTmp(20)
            End If
      End Sub
End Class
0
 

Author Comment

by:mathieu_cupryk
ID: 18798872
I need two classes one for
getting values for the divisions

 Public GetDivisionValuesinArrary()

and then hidding the globals.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

719 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