Structures en VB.Net

podorn Messages postés 7 Date d'inscription mardi 29 avril 2003 Statut Membre Dernière intervention 9 août 2006 - 13 juin 2006 à 02:24
ShareVB Messages postés 2676 Date d'inscription vendredi 28 juin 2002 Statut Membre Dernière intervention 13 janvier 2016 - 14 juin 2006 à 18:54
Salut à tous ,
Quelqu'un pourrait -il m'aider a comprendre pourquoi ce code ne marche pas
    Public Structure SiteAoptimiser
        Public NomDuSite As String
        Dim AxeXYTilt() As Double
        Dim AxeXYAzimut() As Double
        Dim AxeXYPuissance() As Double
        Dim AxeXYIntraDl() As Double
        Dim AxeXYIntraUl() As Double
        Dim AxeXYInterDl() As Double
        Dim AxeXYInterUl() As Double
        Public Sub Initialize()
            ReDim AxeXYAzimut(20)
            ReDim AxeXYPuissance(20)
            ReDim AxeXYIntraDl(20)
            ReDim AxeXYIntraUl(20)
            ReDim AxeXYInterDl(20)
            ReDim AxeXYInterUl(20)
        End Sub
    End Structure

    Public Sub creationReseau(ByVal NomDusite As String)
        Dim site1 As String
        Dim compteur, i, j As Integer
        Dim site As SiteAoptimiser = New SiteAoptimiser
        Dim currentRows() As DataRow = _
            Me.Parcs_d_antenneTableAdapter.GetData().Select(Nothing, Nothing, DataViewRowState.CurrentRows)

        With site
            .Initialize()
            j = 0
            compteur = currentRows.Length
            .NomDuSite = NomDusite
            For i = 0 To compteur - 1
                site1 = currentRows(i).ItemArray(0).ToString
                If NomDusite = site1 Then
                    If bTilt Then
                        .AxeXYTilt(j) = currentRows(i).ItemArray(3)
                    End If
                    If bAzimut Then
                        .AxeXYAzimut(j) = currentRows(i).ItemArray(4)
                    End If
                    If bPuissance Then
                        .AxeXYPuissance(j) = currentRows(i).ItemArray(5)
                    End If
                    If bInterIntraDL Then
                        .AxeXYIntraDl(j) = currentRows(i).ItemArray(6)
                    End If
                    If bInterIntraUL Then
                        .AxeXYIntraUl(j) = currentRows(i).ItemArray(7)
                    End If
                    If bInterInterDL Then
                        .AxeXYInterDl(j) = currentRows(i).ItemArray(8)
                    End If
                    If bInterInterUL Then
                        .AxeXYInterUl(j) = currentRows(i).ItemArray(9)
                    End If
                End If
                j = j + 1
            Next
            j = 0
            Parc.Add(site)
        End With
    End Sub

Quand il arrive sur la ligne en gras il me renvoi une exception : La référence d'objet n'est pas définie à une instance d'un objet.
Merci d'avance pour l'aide

 podor

2 réponses

Nono8379 Messages postés 6 Date d'inscription samedi 10 janvier 2004 Statut Membre Dernière intervention 4 juillet 2006
13 juin 2006 à 07:19
essaye d'initialiser ton object site a partir de ta classe avant de l'utiliser :

Dim Site As SiteAoptimiser

Arnaud
0
ShareVB Messages postés 2676 Date d'inscription vendredi 28 juin 2002 Statut Membre Dernière intervention 13 janvier 2016 26
14 juin 2006 à 18:54
salut,

je ne me souviens plus si la méthode Initialize est appellée automatique sur la structure crée :
Dim site As SiteAoptimiser = New SiteAoptimiser
site.Initialize()

ShareVB
0
Rejoignez-nous