Solved

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

Posted on 2007-03-26
2
2,791 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now