Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-03-26
2
Medium Priority
?
2,812 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 1500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

715 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