mondico2.save "c:\mondico.dic", False
Sub deux() 'Set o = CreateObject("multi.Dictionary") Set o = CreateObject("Scripting.Dictionary") 'Add some data to the dictionary o.Add "vbNullString", vbNullString o.Add "dbl", CDbl(10) o.Add "sng", CSng(15) o.Add "array", Array(1) o.Add "currency", CCur(11) o.Add "byte", CByte(12) o.Add "int", CInt(13) o.Add "lng", CLng(14) o.Add "string", "Some text" o.Add "bool", True o.Add "empty", Empty o.Add "null", Null 'Save the dictionary to a file o.Save "C:\aa.dic", False 'remove all data from the dictionary o.RemoveAll 'Load the data to the dictionary.from the file o.Load "C:\aa.dic" End Sub
Private Type titi
nom As String * 15
prenom As String * 30
End Type
Private Sub CommandButton1_Click()
Dim enregistrement As titi, unnumero
Open "c:\essai.txt" For Random As #1 Len = Len(enregistrement)
For unnumero = 1 To 5
enregistrement.nom = "un nom" & unnumero As Long
enregistrement.prenom = "un prenom" & unnumero
Put #1, unnumero, enregistrement
Next unnumero
Close #1
End Sub
Private Sub CommandButton2_Click()
Dim enregistrement As titi, maposition As Long
Open "c:\essai.txt" For Random As #1 Len = Len(enregistrement)
For maposition = 1 To 5
Get #1, maposition, enregistrement
MsgBox "enregistrement n° " & maposition & vbCrLf & _
"nom = " & enregistrement.nom & vbCrLf & "prénom = " & enregistrement.prenom
Next maposition
Close #1
End Sub
enregistrement.nom = "un nom" & unnumero As Long
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionMarquer comme résolu
Private Sub CommandButton2_Click()
Dim enregistrement As titi, maposition As Long
Open "c:\essai.txt" For Random As #1 Len = Len(enregistrement)
For maposition = 1 To FileLen("c:\essai.txt") \ Len(enregistrement)
Get #1, maposition, enregistrement
MsgBox "enregistrement n° " & maposition & vbCrLf & _
"nom = " & enregistrement.nom & vbCrLf & "prénom = " & enregistrement.prenom
Next
Close #1
End Sub
Private Type titi
nom As String * 15
prenom As String * 30
End Type
VarString$ = String$(10," ") Put #1,,VarString$
Private Sub CommandButton1_Click()
Dim titi As String, toto As String * 9
titi = "couic"
toto = titi
voyons_clair titi, toto, 1
'------------------------------------------------
MsgBox "voyons alors ce que pourrait également être toto"
toto = Format(titi, "@@@@@@@@@")
voyons_clair titi, toto, 2
MsgBox "pas pareil ... essayons autrement"
Dim tata
toto = "012345678"
LSet toto = titi
voyons_clair titi, toto, 3
MsgBox "ah ! l'essai 3 traduit la même chose que le 1"
toto = titi & String(9 - Len(titi), " ")
voyons_clair titi, toto, 4
MsgBox "ah ! l'essai 4 traduit également la même chose que le 1"
toto = String(Len(titi), " ")
Mid(toto, 1, Len(titi)) = titi
voyons_clair titi, toto, 5
MsgBox "ah ! l'essai 5 traduit également la même chose que le 1"
End Sub
Private Sub voyons_clair(ByVal titi, ByVal toto, essai As Byte)
MsgBox "essai " & essai
MsgBox toto = titi
MsgBox "nous avions pourtant dit que toto = titi !"
MsgBox Len(titi) & " " & Len(toto)
MsgBox "-" & titi & "-" & " " & "-" & toto & "-" & vbCrLf & _
"nous voyons là la différence entre toto et titi ==>> voyons la suite"
For i = 1 To Len(toto)
MsgBox Mid(toto, i, 1) & " caractère n° " & i & " ==>> " & Asc(Mid(toto, i, 1)) & vbCrLf & _
"dans toto"
Next
MsgBox "ah ! çà, alors ! et en effet ===>> " & vbCrLf & Replace(toto, " ", "/")
End Sub
Open "c:\essai.txt" For Random As #1 Len = Len(enregistrement)
toto = 121.3 '====>> un numérique
MsgBox "-" & Format(toto, "0000.00") & "-"
MsgBox "-" & Format(toto, "###") & "-"
MsgBox "-" & Format(toto, "#\x#\%#") & "-"
toto = "121.3" '===>> un string
MsgBox "-" & Format(toto, "@@@@@@@") & "-"
MsgBox "-" & Format(toto, "@@@") & "-"
MsgBox "-" & Format(toto, "@\x\v\o\i\l\à@\%@") & "-"
Private Type titi
nom As String * 15
unedate As Date
stock As Long
End Type
Private Sub CommandButton1_Click()
Randomize Timer
Dim enregistrement As titi, unnumero As Long
Kill "c:\essai.txt"
Open "c:\essai.txt" For Random As #1 Len = Len(enregistrement)
For unnumero = 1 To 5
enregistrement.nom = "un nom" & unnumero
enregistrement.unedate = DateAdd("d", Int((5 * Rnd) + 1), Date)
enregistrement.stock = Int((100000 * Rnd) + 1)
Put #1, unnumero, enregistrement
Next unnumero
Close #1
End Sub
Private Sub CommandButton2_Click()
Dim enregistrement As titi, maposition As Long
Open "c:\essai.txt" For Random As #1 Len = Len(enregistrement)
For maposition = 1 To FileLen("c:\essai.txt") \ Len(enregistrement)
Get #1, maposition, enregistrement
MsgBox "enregistrement n° " & maposition & vbCrLf & _
"nom = " & Trim(enregistrement.nom) & vbCrLf & "ladate = " & enregistrement.unedate & _
vbCrLf & "en stock = " & enregistrement.stock
Next
Close #1
End Sub
si je viens tard sur l'ordi, c'est que j'ai une ravissante fille de 6 ans IEP qui m'accapare beaucoup