[VB.net] code pour ajouter nouveau contact
young style
Messages postés
225
Statut
Membre
-
young style Messages postés 225 Statut Membre -
young style Messages postés 225 Statut Membre -
Bonjour,
mon programme est un répertoire des contacts tél.
J'ai un problème avec le code que j'utilise pour ajouter un nouveau contact au niveau de FilePut(i, co, k)
Pour voir l'interface de quoi il s'agit : https://i80.servimg.com/u/f80/11/70/06/47/11110.jpg
Voilà le code (bouton ajouter)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Bouton: valider l'ajout
Dim k As Integer = 1, nb As Integer
trouve = False
FileOpen(1, "C:\contacts.dat", OpenMode.Random, OpenAccess.ReadWrite, OpenShare.Shared, Len(co))
nb = LOF(1) / Len(co)
While Not EOF(1) And trouve = False
FileGet(1, co, k)
If Trim(co.nom) = Trim(TextBox1.Text) Then
trouve = True
Exit While
Else
k += 1
End If
End While
If trouve = True Then
MsgBox(" existe déja")
Else
k = k + 1
co.nom = TextBox1.Text
co.num_gsm = TextBox2.Text
co.num_dom = TextBox3.Text
co.num_bur = TextBox4.Text
co.mail = TextBox5.Text
co.com = TextBox6.Text
FilePut(1, co, k)
MsgBox(" stocké avec seccus")
End If
FileClose(1)
End Sub
et pour les structures je l'ai enregistré dans un module :
Module Module1
Public Structure contact
<VBFixedString(30)> Public nom As String
<VBFixedString(30)> Public num_gsm As String
<VBFixedString(30)> Public num_dom As String
<VBFixedString(30)> Public num_bur As String
<VBFixedString(100)> Public mail As String
Public com As String
End Structure
Public co As contact
Public trouve As Boolean
Public n As Integer
Public x As String
End Module
mon programme est un répertoire des contacts tél.
J'ai un problème avec le code que j'utilise pour ajouter un nouveau contact au niveau de FilePut(i, co, k)
Pour voir l'interface de quoi il s'agit : https://i80.servimg.com/u/f80/11/70/06/47/11110.jpg
Voilà le code (bouton ajouter)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Bouton: valider l'ajout
Dim k As Integer = 1, nb As Integer
trouve = False
FileOpen(1, "C:\contacts.dat", OpenMode.Random, OpenAccess.ReadWrite, OpenShare.Shared, Len(co))
nb = LOF(1) / Len(co)
While Not EOF(1) And trouve = False
FileGet(1, co, k)
If Trim(co.nom) = Trim(TextBox1.Text) Then
trouve = True
Exit While
Else
k += 1
End If
End While
If trouve = True Then
MsgBox(" existe déja")
Else
k = k + 1
co.nom = TextBox1.Text
co.num_gsm = TextBox2.Text
co.num_dom = TextBox3.Text
co.num_bur = TextBox4.Text
co.mail = TextBox5.Text
co.com = TextBox6.Text
FilePut(1, co, k)
MsgBox(" stocké avec seccus")
End If
FileClose(1)
End Sub
et pour les structures je l'ai enregistré dans un module :
Module Module1
Public Structure contact
<VBFixedString(30)> Public nom As String
<VBFixedString(30)> Public num_gsm As String
<VBFixedString(30)> Public num_dom As String
<VBFixedString(30)> Public num_bur As String
<VBFixedString(100)> Public mail As String
Public com As String
End Structure
Public co As contact
Public trouve As Boolean
Public n As Integer
Public x As String
End Module
A voir également:
- [VB.net] code pour ajouter nouveau contact
- Code ascii - Guide
- Code puk bloqué - Guide
- Comment déverrouiller un téléphone quand on a oublié le code - Guide
- Code activation windows 10 - Guide
- Nouveau site coco chat - Accueil - Réseaux sociaux