Solved

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

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 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

9 Experts available now in Live!

Get 1:1 Help Now