Collection: differenze tra le versioni
Vai alla navigazione
Vai alla ricerca
Nessun oggetto della modifica |
Nessun oggetto della modifica |
||
| Riga 23: | Riga 23: | ||
'''Public''' Sub Button1_Click() | '''Public''' Sub Button1_Click() | ||
Print miaCollezione["primoCampo"] ''<Font Color= #006400>' scrive in console : 64</font> | Print miaCollezione["primoCampo"] ''<Font Color= #006400>' scrive in console : 64''</font> | ||
Print miaCollezione["secondoCampo"] ''<Font Color= #006400>' scrive: 4000</font> | Print miaCollezione["secondoCampo"] ''<Font Color= #006400>' scrive in console: 4000''</font> | ||
Print miaCollezione["terzoCampo"] ''<Font Color= #006400>' scrive: terzoValore</font> | Print miaCollezione["terzoCampo"] ''<Font Color= #006400>' scrive in console: terzoValore''</font> | ||
'''End''' | |||
Ma è possibile anche richiamare un campo di una Collection in un'altra Collection: | |||
''<Font Color= #006400>' Gambas class file''</font> | |||
auto As New Collection | |||
bici As New Collection | |||
'''Public''' Sub Form_Open() | |||
Dim tipo, ruota As Byte | |||
Dim ts, sellino As Integer | |||
tipo = InputBox("Inserisci dato byte:") | |||
ruota = 144 | |||
ts = 4000 | |||
sellino = 10000 | |||
With bici | |||
.add(ruota, "ruota") | |||
.add(sellino, "sellino") | |||
End With | |||
With auto | |||
.add(tipo, "type") | |||
.add(ts, "motore") | |||
.add(123, “numeri”) | |||
.add("coda", "queue") | |||
.add(bici["ruota"], "bicicletta") | |||
End With | |||
'''End''' | |||
'''Public''' Sub Button1_Click() | |||
Print auto["type"] ''<Font Color= #006400>' scrive il valore immesso con l'inputbox''</font> | |||
Print auto["motore"] ''<Font Color= #006400>' scrive: 4000''</font> | |||
Print auto["numeri”] ''<Font Color= #006400>' scrive: 123''</font> | |||
Print auto["queue"] ''<Font Color= #006400>' scrive: coda''</font> | |||
Print auto["q" & "ueue"] ''<Font Color= #006400>' scrive: coda''</font> | |||
Print auto["bicicletta"] ''<Font Color= #006400>' scrive: 144 (campo/valore dell'altra Collction “bicicletta”)''</font> | |||
'''End''' | '''End''' | ||
Versione delle 11:12, 17 gen 2012
' Gambas class file
miaCollezione As New Collection
Public Sub Button1_Click()
Dim primoValore As Byte
Dim secondoValore As Integer
primoValore = 64
secondoValore = 4000
With miaCollezione
.add(primoValore, "primoCampo")
.add(secondoValore, "secondoCampo")
.add("terzoValore", "terzoCampo")
End With
End
Public Sub Button1_Click()
Print miaCollezione["primoCampo"] ' scrive in console : 64
Print miaCollezione["secondoCampo"] ' scrive in console: 4000
Print miaCollezione["terzoCampo"] ' scrive in console: terzoValore
End
Ma è possibile anche richiamare un campo di una Collection in un'altra Collection:
' Gambas class file
auto As New Collection
bici As New Collection
Public Sub Form_Open()
Dim tipo, ruota As Byte
Dim ts, sellino As Integer
tipo = InputBox("Inserisci dato byte:")
ruota = 144
ts = 4000
sellino = 10000
With bici
.add(ruota, "ruota")
.add(sellino, "sellino")
End With
With auto
.add(tipo, "type")
.add(ts, "motore")
.add(123, “numeri”)
.add("coda", "queue")
.add(bici["ruota"], "bicicletta")
End With
End
Public Sub Button1_Click()
Print auto["type"] ' scrive il valore immesso con l'inputbox
Print auto["motore"] ' scrive: 4000
Print auto["numeri”] ' scrive: 123
Print auto["queue"] ' scrive: coda
Print auto["q" & "ueue"] ' scrive: coda
Print auto["bicicletta"] ' scrive: 144 (campo/valore dell'altra Collction “bicicletta”)
End