SOS VB.NET tableau multi dimensionnel
Résolu
suuuif
Messages postés
13
Date d'inscription
Statut
Membre
Dernière intervention
-
suuuif Messages postés 13 Date d'inscription Statut Membre Dernière intervention -
suuuif Messages postés 13 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
En VB.NET 2010 je suis confronté à une erreur face à un transfert des valeurs d'un tableau multidimensionnel à un tableau unidimensionnel.
Voici mon code:
En VB.NET 2010 je suis confronté à une erreur face à un transfert des valeurs d'un tableau multidimensionnel à un tableau unidimensionnel.
Voici mon code:
For i = 0 To UBound(tabSemiFini, 1)
j = 0
Do While j <= UBound(tabSemiFini, 2)
Select Case j
Case 0
arrDate(i) = tabSemiFini(i, j)
Case 1
arrHeure(i) = tabSemiFini(i, j)
Case 2
If tabSemiFini(i, j) = "SENT" Then
strEtat(i) = tabSemiFini(i, j)
Else
strEtat(i) = tabSemiFini(i, j + 1)
End If
Case 4
strSMSC(i) = tabSemiFini(i, j)
Case 5
strSVC(i) = tabSemiFini(i, j)
Case 6
strACT(i) = tabSemiFini(i, j)
Case 7
strBINF(i) = tabSemiFini(i, j)
Case 8
strFrom(i) = tabSemiFini(i, j)
Case 9
strExpediteur(i) = tabSemiFini(i, j)
Case 10
strFlags(i) = tabSemiFini(i, j)
Case 11
intTaille(i) = tabSemiFini(i, j)
Case 12
For j = 12 To UBound(tabSemiFini, 2) - 1
strMsg(i) = strMsg(i) & " " & tabSemiFini(i, j)
If tabSemiFini(i, j + 1) = "[udh:0:]" Then
strUDH(i) = tabSemiFini(i, j + 1)
End If
Exit For
Next j
End Select
j = j + 1
Loop
1 réponse
-
Juste dire que j'ai trouvé la solution il suffisait juste de changer ma méthode
Et voici la soluce:Private Sub TraiterLeLogToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TraiterLeLogToolStripMenuItem.Click Dim nLignes() As String = txtLog.Lines 'Decoupe le texte principal par ligne Dim i, j As Integer Dim tampon(0) As String Dim Taille As Integer Dim tabTri() As String = txtLog.Lines 'Affectation du contenu du 1er Tableau pour preserver son contenu 'Determine la valeur de la ligne la plus longue Taille = 0 For i = 0 To UBound(tabTri) If Taille < tabTri(i).Length Then Taille = tabTri(i).Length End If Next i MsgBox("la taille maxi est :" & Taille) 'Decoupe chaque ligne par mots Dim tabSemifini(UBound(nLignes), Taille) As String Dim LigneTempo As String = "" 'Tableau temporaire reçoit la ligne decoupé en chaînes For i = 0 To UBound(nLignes) LigneTempo = nLignes(i) Dim Tabtempo() As String = LigneTempo.Split(" ") For j = 0 To UBound(Tabtempo) tabSemifini(i, j) = Tabtempo(j) Next j Next i 'Test de verification (Test passé avec succès) For i = 0 To UBound(tabSemifini, 1) For j = 0 To UBound(tabSemifini, 2) If tabSemifini(i, j + 1) = "" Then Exit For Next j Next i Dim strDate(UBound(nLignes)) As Date Dim strHeure(UBound(nLignes)) As Date Dim strEtat(UBound(nLignes)) As String Dim strExpediteur(UBound(nLignes)) As String Dim strDestinataire(UBound(nLignes)) As String Dim strSMSC(UBound(nLignes)) As String Dim strSVC(UBound(nLignes)) As String Dim strACT(UBound(nLignes)) As String Dim strFID(UBound(nLignes)) As String Dim strBINF(UBound(nLignes)) As String Dim strFrom(UBound(nLignes)) As String Dim strFlags(UBound(nLignes)) As String Dim strUDH(UBound(nLignes)) As String Dim strMsg(UBound(nLignes)) As String Dim strTaille(UBound(nLignes)) As String For i = 0 To UBound(tabSemifini, 1) For j = 0 To UBound(tabSemifini, 2) Dim y As Integer If tabSemifini(i, j) <> "" Then Select Case j Case 0 strDate(i) = tabSemifini(i, j) Case 1 strHeure(i) = tabSemifini(i, j) Case 2 If tabSemifini(i, j) = "SENT" Then strEtat(i) = tabSemifini(i, j) Else strEtat(i) = tabSemifini(i, j + 1) End If Case 4 strSMSC(i) = tabSemifini(i, j) Case 5 strSVC(i) = tabSemifini(i, j) Case 6 strACT(i) = tabSemifini(i, j) Case 7 strBINF(i) = tabSemifini(i, j) Case 8 strFID(i) = tabSemifini(i, j) Case 9 strExpediteur(i) = tabSemifini(i, j) Case 10 strDestinataire(i) = tabSemifini(i, j) Case 11 strFlags(i) = tabSemifini(i, j) Case 12 strTaille(i) = tabSemifini(i, j) Case 13 For y = j To UBound(tabSemifini, 2) If tabSemifini(i, y) <> "[UDH:0]" And tabSemifini(i, y) <> "" Then strMsg(i) = strMsg(i) & " " & tabSemifini(i, y) ElseIf tabSemifini(i, j) = "[UDH:0]" Then strUDH(i) = tabSemifini(i, y) Else : Exit For End If Next y End Select Else : Exit For End If Next j Next i 'Test de vérité Dim tempo As String = "" For i = 0 To 2 tempo = strDate(i) & vbTab & strHeure(i) & vbTab & strEtat(i) & vbTab & strSMSC(i) & vbTab & _ strSVC(i) & vbTab & strACT(i) & vbTab & strBINF(i) & vbTab & strFID(i) & vbCrLf _ & strExpediteur(i) & vbTab & strDestinataire(i) & vbTab & strFlags(i) & vbCrLf _ & strTaille(i) & vbTab & strUDH(i) & vbCrLf & strMsg(i) MsgBox(tempo, MsgBoxStyle.Information) Next i End Sub