Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim sr As StreamReader = New StreamReader("c:\test1.test") Dim all As String = sr.ReadToEnd Dim split() As String = all.Split(";").ToArray Dim table(split.Length - 1)() As String ' tu initialises ton tableau avec le nombre de ligne For i = 0 To split.Length - 1 'ici split.Length - 1 sinon tu vas trop loin dans ton tableau split Dim id As String Dim name As String Dim phone As String Dim a() As String = split(i).Split("/").ToArray id = a(0) name = a(1) phone = a(2) ReDim table(i)(2) 'ici tu règles le nombre d’éléments par ligne table(i)(0) = a(0) table(i)(1) = a(1) table(i)(2) = a(2) Next End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPublic Class Personne Private mid As String Private mName As String Private mphone As String Public Property id() As String Get Return mid End Get Set(ByVal value As String) mid = value End Set End Property Public Property Name() As String Get Return mName End Get Set(ByVal value As String) mName = value End Set End Property Public Property phone() As String Get Return mphone End Get Set(ByVal value As String) mphone = value End Set End Property Public Sub AddPersonne(ByVal id As String, ByVal name As String, ByVal phone As String) mid = id mName = name mphone = phone End Sub End Class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim sr As StreamReader = New StreamReader("c:\test1.test") Dim all As String = sr.ReadToEnd Dim split() As String = all.Split(";").ToArray Dim table As List(Of Personne) = New List(Of Personne) For i = 0 To split.Length - 1 'à chaque boucle tu crées une personne et tu l'ajoutes à ta liste Dim a() As String = split(i).Split("/").ToArray Dim personne As New Personne personne.AddPersonne( a(0), a(1),a(2)) Next End Sub
Dim table As List(Of Personne) = New List(Of Personne)
Dim table As new List(Of Personne)
Dim table As List(Of Personne) = New List(Of Personne) Dim table As new List(Of Personne)
table = Nothing