Instanciation d'une classe

joujma5 Messages postés 152 Date d'inscription samedi 11 novembre 2006 Statut Membre Dernière intervention 5 décembre 2014 - 30 mai 2013 à 15:47
ToutEnMasm Messages postés 587 Date d'inscription jeudi 28 novembre 2002 Statut Membre Dernière intervention 13 décembre 2022 - 30 mai 2013 à 16:47
Bonjour,
j'ai une classe nommée class1 dans laquelle j'ai définie les variables connection string récupérés d'un fichier texte
Public chainePrint, chaineReg, chaine As String 

avec le code suivant:

public instance as new class1

Private Sub MDIParent1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If My.Application.CommandLineArgs.Count > 0 Then
            Try
                ' Création d'une instance de StreamReader pour permettre la lecture de notre fichier
                Dim monStreamReader As StreamReader = New StreamReader(My.Application.CommandLineArgs(0))
                Dim ligne As String

                'Lecture de toutes les lignes et affichage de chacune sur la page
                'Dim server, basereg, basecom, baseprint, user, psw, integrated As String
                Dim x As Integer = 0
                Do

                    ligne = monStreamReader.ReadLine()
                    If x = 0 Then
                        server = ligne.Substring(9)
                    ElseIf x = 1 Then
                        user = ligne.Substring(6)
                    ElseIf x = 2 Then
                        psw = ligne.Substring(12)
                    ElseIf x = 3 Then
                        basecom = ligne.Substring(20)
                    ElseIf x = 4 Then
                        basereg = ligne.Substring(19)
                    ElseIf x = 5 Then
                        integrated = ligne.Substring(12)
                    End If
                    x = x + 1
                Loop Until ligne Is Nothing

                instance.chaineReg = "Data Source=" & server & "Initial Catalog=" & basereg & "Integrated Security=True"
                instance.chaine = "Data Source=" & server & "Initial Catalog=" & basecom & "Integrated Security=True"
                instance.chainePrint = "Data Source=" & server & "Initial Catalog=" & baseprint & "Integrated Security=True"
                'Fermeture du StreamReader (attention très important)
                monStreamReader.Close()

                
            Catch ex As Exception
                'Code exécuté en cas d'exception
                MsgBox(ex.Message)
            End Try
        
        End If
    End Sub


dans ma classe j'ai une public sub nommé
"Stat_Pointeur()" et c'est le départ du problème car lorsque j'instancie ma classe avec :
dim instance as new class1

et que je fais appel à la public sub "stat_pointeur" comme ça:
instance.stat_pointeur

le programme me retourne "la propriété connectionstring n'a pas été initialisé".
Quelqu'un a une idée comment remédier à ce problème.

1 réponse

ToutEnMasm Messages postés 587 Date d'inscription jeudi 28 novembre 2002 Statut Membre Dernière intervention 13 décembre 2022 3
30 mai 2013 à 16:47
içi c'est le forum assembleur,peut être que dans le forum Visual Basic ? (VB).
0
Rejoignez-nous