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 40 41 42 43 44 45 46 47
| Structure exempl
Dim Str1 As String
End Structure
Sub Ess25()
'----------------------------------------------------
'Exemple 1 Déclaration de la structure une seule fois
Dim Stc_Exem As exempl = Nothing
Dim IntInd As Integer = 0
Do Until IntInd = 1000
Stc_Exem = New exempl
Stc_Exem.Str1 = "Bla"
'Utilise la variable
Console.WriteLine(String.Format("{0} {1}", Stc_Exem.Str1, IntInd))
'
'
'
'Destruction de la structure
Stc_Exem = Nothing
IntInd += 1
Loop
IntInd = 0
'----------------------------------------------------
'Exemple 2 Créer une nouvelle structure à chaque tour
Do Until IntInd = 1000
Dim Stc_Exem2 As New exempl
Stc_Exem2.Str1 = "Bla"
'Utilise la variable
Console.WriteLine(String.Format("{0} {1}", Stc_Exem2.Str1, IntInd))
'
'
'
'Destruction de la structure
Stc_Exem2 = Nothing
IntInd += 1
Loop
'----------------------------------------------------
End Sub |
Partager