1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| Private Sub Save()
'crée un fichier de sauvegarde
Dim FileSave As New IO.StreamWriter("C:\Test.txt", IO.FileMode.Create)
For Each Con As Windows.Forms.Control In Me.Controls
If TypeOf Con Is Windows.Forms.TextBox Then 'ici le controle est une Textbox
Dim data As String = Con.Name & "||||" & Con.Text
FileSave.Write(data & vbCrLf)
ElseIf TypeOf Con Is Windows.Forms.CheckBox Then 'ici c'est une combobox
Dim data As String = Con.Name & "||||" & CType(Con, Windows.Forms.CheckBox).Checked.ToString
FileSave.Write(data & vbCrLf)
Else
'ce que tu veux la
End If
Next
FileSave.Close()
End Sub |