Pb avec insertion valeur ds tableau
Bonsoir,
Je suis débutant et en train de réaliser mon 1er développement en VB.net.
Je n'arrive pas a distribuer un tableau dans 2 autres tableaux suivant la valeur de 1er champ
Voici le code
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
If OFD.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim sr As StreamReader = New StreamReader(OFD.FileName)
Dim TAB() As String
Dim DNS_Tab(0, 0) As String
Dim Port_Tab(0, 0) As String
Dim Ligne As String
Dim Nblines_DNS, Nblines_Port As Integer
sr = New StreamReader(OFD.FileName)
Ligne = ""
Nblines_DNS = 0
Nblines_Port = 0
TAB = Nothing
DNS_Tab = Nothing
Port_Tab = Nothing
Ligne = sr.ReadLine()
While Not Ligne = Nothing
TAB = Ligne.Split(";")
If TAB(0) = "DNS" Then
ReDim Preserve DNS_Tab(Nblines_DNS, TAB.Length)
DNS_Tab(Nblines_DNS, TAB.Length) = TAB(0).ToString
Nblines_DNS = Nblines_DNS + 1
End If
If TAB(0) = "Port" Then
ReDim Preserve DNS_Tab(Nblines_Port, TAB.Length)
DNS_Tab(Nblines_Port, TAB.Length) = TAB(0).ToString
Nblines_Port = Nblines_Port + 1
End If
TAB = Nothing
Ligne = sr.ReadLine()
End While
sr.Close()
Else
MsgBox("veuillez choisir un fichier")
End If |
Dc je charge un fichier ou les ligne n'ont pas toute le même nombre de champs. J'ai deux type de composition possibles maxi qui dépendent de la valeur du 1er champ (TAB(0)). De ce fait je fait bien un test conditionnel sur Tab(0) = pas de pb. Par contre je n'arrive pas a copier la valeur TAB(x) dans le 2eme tableau.
Quelqu'un pourrait m'expliquer ce que j'ai manqué?
Merci d'avance
Anax