Visual Basic | Probléme de formulaire d'inscription.

Résolu/Fermé
Freakin Messages postés 77 Date d'inscription jeudi 10 janvier 2013 Statut Membre Dernière intervention 26 août 2013 - 18 août 2013 à 10:23
Freakin Messages postés 77 Date d'inscription jeudi 10 janvier 2013 Statut Membre Dernière intervention 26 août 2013 - 18 août 2013 à 19:28
Bonjour à tous, je voudrais savoir comment faire pour faire plusieurs inscription, je m'explique:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If (Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\" & "Inscrition - MenuProHacker - Team.txt") Then

Dim SS As New System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\" & "Inscrition - MenuProHacker - Team | 2.txt")

SS.WriteLine(TextBox1.Text)
SS.WriteLine(TextBox3.Text)
SS.Close()
MsgBox("Votre compte a bien été enregistrer !", MsgBoxStyle.Information, ("Compte"))
Form1.Show()
Me.Close()

Else

Dim SW As New System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\" & "Inscrition - MenuProHacker - Team.txt")

SW.WriteLine(TextBox1.Text)
SW.WriteLine(TextBox3.Text)
SW.Close()
MsgBox("Votre compte a bien été enregistrer !", MsgBoxStyle.Information, ("Compte"))
Form1.Show()
Me.Close()

End If

End Sub


--------------------------------------------------------------------------------------------------------

ou même avec ce code cela ne fonctionne pas :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim SW As New System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\" & "Inscrition - MenuProHacker - Team.txt")

SW.WriteLine(TextBox1.Text)
SW.WriteLine(TextBox3.Text)
SW.Close()
MsgBox("Votre compte a bien été enregistrer !", MsgBoxStyle.Information, ("Compte"))
Form1.Show()
Me.Close()
If Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\" & "Inscrition - MenuProHacker - Team.txt" = True Then

Dim SS As New System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\" & "Inscrition - MenuProHacker - Team | 2.txt")

SS.WriteLine(TextBox1.Text)
SS.WriteLine(TextBox3.Text)
SS.Close()
MsgBox("Votre compte a bien été enregistrer !", MsgBoxStyle.Information, ("Compte"))
Form1.Show()
Me.Close()

End If

-------------------------------------------------------------------------------------------------------

Voila donc la sa veut pas enregistrez 2 inscription, sa me dit :
"La conversion de la chaîne "C:\Users\TahFl-91\Documents\Insc" en type 'Boolean' n'est pas valide."

Mais quand je met qu'un seul endroit ou fichier texte a enregistrez pour 1seul compte, cela fonctionne tres bien.

Voila je voudrais juste savoir sa svp.
A voir également:

1 réponse

MrYAU31 Messages postés 3808 Date d'inscription samedi 23 février 2013 Statut Membre Dernière intervention 8 juillet 2017 1 611
Modifié par MrYAU31 le 18/08/2013 à 10:37
Bonjour,
Quand tu fais
If Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\" & "Inscrition - MenuProHacker - Team.txt" = True Then 

Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\" & "Inscrition - MenuProHacker - Team.txt" te renverra le chemin vers Inscrition - MenuProHacker - Team.txt (comme C:\Users\Moi\Mes Documents\Inscrition - MenuProHacker - Team.txt). Tu ne peux pas tester s'il a la valeur True or False. Si tu veux savoir s'il existe, utilise Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\" & "Inscrition - MenuProHacker - Team.txt")
qui te renverra bien True ou False.
0
Freakin Messages postés 77 Date d'inscription jeudi 10 janvier 2013 Statut Membre Dernière intervention 26 août 2013 3
Modifié par Freakin le 18/08/2013 à 18:06
Merci de ton aide, mais sur Visual Basic sa n'existe pas: "Exists" j'ai bien essayer, mais apparament sa fonctionne qu'en Batch.
0
MrYAU31 Messages postés 3808 Date d'inscription samedi 23 février 2013 Statut Membre Dernière intervention 8 juillet 2017 1 611
Modifié par MrYAU31 le 18/08/2013 à 18:17
Tu n'as peut-être pas les Imports qu'il faut.
Fais System.IO.File.Exists à la place de Exists.
Ou ajoute un Imports System.IO.File au début du code de ta form.
0
Freakin Messages postés 77 Date d'inscription jeudi 10 janvier 2013 Statut Membre Dernière intervention 26 août 2013 3
18 août 2013 à 18:25
Merci, cela fonctionne mais encore une question, désolé ^^

Mais quand je sa crée le premier fichier le deuxième se crée automatiquement, cela est normal car il détecte que le premier Existe, mais je veut que le deuxième fichier se crée que si l'utilisateur se crée un autre compte, enfin qu'il clique sur confirmez l'inscription & je sais pas comment faire car tout est dans le boutton1.

Merci de ton aide ;)
0
MrYAU31 Messages postés 3808 Date d'inscription samedi 23 février 2013 Statut Membre Dernière intervention 8 juillet 2017 1 611
Modifié par MrYAU31 le 18/08/2013 à 18:29
Sur ton 1er code ou ton 2ème ?
Avec le 1er, tu as ta condition IF qui ne devrait pas faire de création du second fichier si le fichier du premier compte n'existe pas...
Tu penses bien à supprimer ton fichier une fois le compte créé ?
0
Freakin Messages postés 77 Date d'inscription jeudi 10 janvier 2013 Statut Membre Dernière intervention 26 août 2013 3
18 août 2013 à 18:33
Alors, oui j'utilise la fonctionne " if " et je ne supprime pas le fichier parce-que je dit au programme que regarder dans le fichier texte, si je le supprime il n'y a plus d'identifiant ect.
je te réenvoie mon code :

CODE :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim SW As New System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\" & "Inscrition - MenuProHacker - Team.txt")

SW.WriteLine(TextBox1.Text)
SW.WriteLine(TextBox3.Text)
SW.Close()
MsgBox("Votre compte a bien été enregistrer !", MsgBoxStyle.Information, ("Compte"))
Form1.Show()
Me.Close()

If Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\" & "Inscrition - MenuProHacker - Team.txt") Then

Dim SS As New System.IO.StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) & "\" & "Inscrition - MenuProHacker - Team2.txt")

SS.WriteLine(TextBox1.Text)
SS.WriteLine(TextBox3.Text)
SS.Close()
MsgBox("Votre compte a bien été enregistrer !", MsgBoxStyle.Information, ("Compte"))
Form1.Show()
Me.Close()

End If
0