[VB 2005]Effacer une ligne dans un tableau

Résolu
Clad49 Messages postés 265 Date d'inscription dimanche 3 août 2003 Statut Membre Dernière intervention 29 mars 2010 - 20 janv. 2007 à 14:44
 Utilisateur anonyme - 20 janv. 2007 à 15:45
Bonjour !

Voila j'ai un tableau a plusieur dimention déclaré comme ceci :

    Public Structure tformat
        Dim tId As String
        Dim tNom As String
        Dim tPrenom As String
        Dim tEmail As String
        ...
    End Structure

Public Tableau() As tformat

Et j'aurai voulu savoir comment faire pour supprimer des éléments ?
Je sais que c'est faisable avec Array.Copy mais je ne sais pas si c'est faisable dans mon cas !
(du moins je n'y arrive pas :s )

Merci
Clad

4 réponses

Utilisateur anonyme
20 janv. 2007 à 15:18
Salut,

Oui, faisable avec copy :



Private Sub RemoveItem(ByRef Tab() As tformat, ByVal Index As Integer)
  System.Array.Copy(Tab, Index + 1, Tab, Index, Tab.Length - Index - 1)
  System.Array.Resize(Of tformat)(Tab, Tab.Length - 1)
End Sub,

----

(Coloration syntaxique automatique par Kenji)





__________
Kenji
3
Utilisateur anonyme
20 janv. 2007 à 15:45
Voir aide en ligne :

http://msdn2.microsoft.com/fr-fr/library/system.array.sort(VS.80).aspx




System.Array.Sort(Of tformat)(Tableau, AddressOf Comparetformat)

Private Function Comparetformat(ByVal x As tformat, ByVal y As tformat) As Integer
  If x.tId < y.tId Then Return -1
  If x.tId = y.tId Then Return 0
  If x.tId > y.tId Then Return 1
End Function,

----

(Coloration syntaxique automatique par Kenji)





__________
Kenji
3
Clad49 Messages postés 265 Date d'inscription dimanche 3 août 2003 Statut Membre Dernière intervention 29 mars 2010
20 janv. 2007 à 15:26
Je te remerci beaucoup ca marche nikel ;)

Clad
0
Clad49 Messages postés 265 Date d'inscription dimanche 3 août 2003 Statut Membre Dernière intervention 29 mars 2010
20 janv. 2007 à 15:32
Ah si pendant que tu es là ;)

Connait tu un system pour trier ce genre de tableau avec Array.Sort ?

Merci
Clad
0
Rejoignez-nous