Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Another .NET Newby Question
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Titre:
Another .NET Newby Question
Divers
Thread ID:
00977955
Message ID:
00977955
Vues:
61
I have a VB.Net app. I have created a startup module. In it I create an instance of my Application object. In the app object I create other required objects such as the menu, toolbars, SQL Connection, etc.

Problem is I can't see references to these other objects anwhere else except in the class I created them in.

My code:
Module Startup

  Public oApplication As New AppObject

  Public Sub Main()

    oApplication.StartApp()

  End Sub

End Module
And the application class. None of the objects created before the sub are visible anywhere else except in this class.
Imports System.Data
Imports System.Data.SqlClient

Public Class AppObject

    ' DLLs
    Public oGenProcs As New DotNetGenProcs.DotNetGenProcs
    Public oSQLStuff As New SQLStuff.GetSQLConnString

    ' Properties
    Public sConnString As String

    ' Solution level objects
    Public oMenu As New AppMenu            ' Menu class
    Public oToolbars As New AppToolbars    ' Toolbar class
    Public oForm As New frmApplication     ' Application form


    Public Sub StartApp()

        'Load DLL's used in this application
        LoadDLLs()

        ' Set up the SQL connection string
        SetupConnString()

        ' Load the menu from the menu class
        oMenu.LoadMenu(oForm)

        ' Show the toolbars here
        oToolbars.LoadToolbars(oForm)

        ' Set up the background form
        SetupGUI(oForm)

        ' Display the application form
        Application.Run(oForm)

    End Sub

    Private Sub SetupGUI(ByVal oForm As frmApplication)
    End Sub

    Private Sub LoadDLLs()

        ' General procedures library
        Dim _oGenProcs As DotNetGenProcs.DotNetGenProcs
        oGenProcs = _oGenProcs

    End Sub

    Private Sub SetupConnString()

        '************************************************************
        ' Use the SQLStuff DLL to create a SQL Connection string
        '************************************************************
        With oSQLStuff

            .sDataSource = "(local)"
            .sInitialCatalog = "Northwind"
            .sUserId = "someone"
            .sPassword = "password

            sConnString = .sConnString

        End With

    End Sub

    Public Function OpenConnection() As SqlConnection

        ' Set up the return value
        Dim oRetVal As SqlConnection
        oRetVal = Nothing

        ' Create the connection
        Dim oConnection = New SqlConnection(Me.sConnString)
        oConnection.Open()

        ' If the connectin was opened, set the return value
        ' to to the connection, otherwise set it to Nothing.
        If oConnection.State = ConnectionState.Open Then
            oRetVal = oConnection
        Else
            oRetVal = Nothing
        End If

        ' Return the return value
        OpenConnection = oRetVal

    End Function

End Class
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform