IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB.NET Discussion :

Enregistrer le contenu d'un tableau


Sujet :

VB.NET

  1. #1
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2013
    Messages
    31
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 36
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Conseil

    Informations forums :
    Inscription : Mars 2013
    Messages : 31
    Points : 24
    Points
    24
    Par défaut Enregistrer le contenu d'un tableau
    Salut,

    Voila j'ai un form contient un textbox et un tableau et deux boutons (ajouter, enregistrer).

    1) Lorsque j'ajoute un nom dans le textbox et je click sur le bouton ajouter le nom sera ajouter au tableau -----> sa marche
    2) lorsque je click sur le bouton enregistrer le contenue de tableau sera enregistrer dans un fichier.txt et lorsque je compile autre fois je trouve ses contenue dans le tableau.
    Aidez-moi SVP

  2. #2
    Membre averti Avatar de Vince
    Profil pro
    Inscrit en
    Mars 2002
    Messages
    369
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mars 2002
    Messages : 369
    Points : 366
    Points
    366
    Par défaut
    Poste ton code...

  3. #3
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2013
    Messages
    31
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 36
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Conseil

    Informations forums :
    Inscription : Mars 2013
    Messages : 31
    Points : 24
    Points
    24
    Par défaut Enregistrer le contenu d'un tableau
    code est:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
     
    Imports System.IO
    Imports System.Runtime.Serialization.Formatters.Binary
    Public Class Form1
        Dim l As New ArrayList
     
        Dim i As Integer 
        Dim PCourant As Integer = 0 
        Dim Mode As Integer = 1 
        Dim Typ As String 
        Dim p As New place1
        Dim f As New place2
        Dim t As New place3
        Dim r As New place4
     
        Private Sub ButtonAfficher_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
            MajDGV()
        End Sub
        Public Sub MajDGV()
            DGV.Rows.Clear()
            Dim i As Integer
            For i = 0 To l.Count - 1
                DGV.Rows.Add(l.Item(i).GetType.Name, l.Item(i).ToString)
            Next
        End Sub
        Private Sub ButtonAjouter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonAjouter.Click
            Mode = 1
            ComboBox1.Visible = True
        End Sub
        Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
            Typ = ComboBox1.Text
            GroupBox1.Visible = True
            ComboBox1.Visible = False
            GroupBox1.Text = "Nouveau " & ComboBox1.Text
     
        End Sub
        Private Sub ButtonOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOK.Click
     
            If Typ = "place1" Then
                newplace1()
            ElseIf Typ = "place2" Then
                Newplace2()
     
            ElseIf Typ = "place3" Then
                newplace3()
            ElseIf Typ = "place4" Then
                newplace4()
            End If
        End Sub
        Public Sub newplace1()
            p.x = TextBoxX.Text
     
            If Mode = 1 Then
                l.Add(p)
            ElseIf Mode = 2 Then
                l.Item(DGV.CurrentRow.Index).x = TextBoxX.Text
     
            End If
            MajDGV()
        End Sub
     
        Public Sub Newplace2()
            f.x = TextBoxX.Text
     
            If Mode = 1 Then
                l.Add(f)
            ElseIf Mode = 2 Then
                l.Item(DGV.CurrentRow.Index).x = TextBoxX.Text
     
            End If
            MajDGV()
     
     
        End Sub
        Public Sub Newplace3()
            t.x = TextBoxX.Text
     
            If Mode = 1 Then
                l.Add(t)
            ElseIf Mode = 2 Then
                l.Item(DGV.CurrentRow.Index).x = TextBoxX.Text
     
            End If
            MajDGV()
     
     
        End Sub
        Public Sub Newplace4()
            r.x = TextBoxX.Text
     
            If Mode = 1 Then
                l.Add(r)
            ElseIf Mode = 2 Then
                l.Item(DGV.CurrentRow.Index).x = TextBoxX.Text
     
            End If
            MajDGV()
     
     
        End Sub
        Private Sub ButtonModifier_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonModifier.Click
     
            Mode = 2
            Typ = l.Item(DGV.CurrentRow.Index).GetType.Name
            GroupBox1.Text = "Nouveau " & Typ
        End Sub
        Private Sub ButtonSupprimer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSupprimer.Click
            l.RemoveAt(DGV.CurrentRow.Index)
            MajDGV()
        End Sub
     
        Private Sub ButtonEnregistrer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonEnregistrer.Click
        End Sub
        Public Sub enregistrer()
     
            Dim f As FileStream = File.Create("fich.txt")
            Dim s As New BinaryFormatter
            s.Serialize(f, l)
            f.Close()
        End Sub
     
        Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
            Dim res As MsgBoxResult = MsgBox("voulez vous enregistrer", MsgBoxStyle.YesNoCancel, MsgBoxStyle.Exclamation)
            If res = MsgBoxResult.Yes Then
                enregistrer()
            ElseIf res = MsgBoxResult.Cancel Then
                e.Cancel = True
            End If
        End Sub
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
     
            MajDGV()
        End Sub
     
    End Class

  4. #4
    Membre régulier
    Homme Profil pro
    Technicien Help Desk
    Inscrit en
    Novembre 2006
    Messages
    129
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Technicien Help Desk
    Secteur : Bâtiment Travaux Publics

    Informations forums :
    Inscription : Novembre 2006
    Messages : 129
    Points : 106
    Points
    106
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    Private Sub ButtonEnregistrer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonEnregistrer.Click
        End Sub
    Manque la fonction à appeler... du coup il ne se passe rien quand tu clique sur le bouton.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    Private Sub ButtonEnregistrer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonEnregistrer.Click
    Call enregistrer()    
    End Sub

  5. #5
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2013
    Messages
    31
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 36
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Conseil

    Informations forums :
    Inscription : Mars 2013
    Messages : 31
    Points : 24
    Points
    24
    Par défaut
    Désole,

    j'ajoute la fonction à appeler mais ne fonctionne pas.

  6. #6
    Membre à l'essai
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2013
    Messages
    31
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 36
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Conseil

    Informations forums :
    Inscription : Mars 2013
    Messages : 31
    Points : 24
    Points
    24
    Par défaut
    Désole,

    j'ajoute la fonction à appeler mais ne fonctionne pas
    je trouve le fichiers et pas des erreurs mais les contenue de tableau ne sont pas enregistrer

  7. #7
    Membre régulier
    Homme Profil pro
    Technicien Help Desk
    Inscrit en
    Novembre 2006
    Messages
    129
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Technicien Help Desk
    Secteur : Bâtiment Travaux Publics

    Informations forums :
    Inscription : Novembre 2006
    Messages : 129
    Points : 106
    Points
    106

Discussions similaires

  1. Réponses: 3
    Dernier message: 29/12/2014, 18h30
  2. [Débutant] Enregistrer le contenu d'un tableau en fichier Exel
    Par Crowww dans le forum VB.NET
    Réponses: 7
    Dernier message: 02/07/2014, 13h58
  3. Enregistrer le contenu d'un tableau en BDD
    Par albund dans le forum Général JavaScript
    Réponses: 4
    Dernier message: 18/07/2012, 15h58
  4. Réponses: 1
    Dernier message: 14/06/2010, 11h02
  5. Enregistrer le contenu d'un tableau dans un fichier
    Par solicel dans le forum Général JavaScript
    Réponses: 8
    Dernier message: 16/11/2009, 16h50

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo