Projet sur VB 2010 Express

Résolu
Bonjour,
J'ai un projet informatique à réalisé sur VB 2010 Express. J'ai un soucis d'affichage de fenêtre. J'ai une fenêtre principale qui est censé s'ouvrir en premier. Sur cette fenêtre j'ai un bouton "ajouter" qui ouvre une seconde fenêtre. Seulement quand j'exécute mon programme il ouvre directement la seconde feuille. J'ai beau tourner et retourner mon programme dans tous les sens je ne vois pas ou se trouve le soucis.
Est ce que quelqu'un pense pouvoir m'aider??????,

8 réponses

  1. et l'autre qui t'explique à tellement l'air con....
    et moi je fais comme ci et moi je fais comme ca... a ha ha ha ha ah ha ah ah ah ah ahah ridiculus va
    1. J'ai un nouveau soucis
      J'ai relié mes boutons
      Il marche (enfin presque)
      Seulement pour faire marcher mon second bouton , si j'ai cliquer sur le bouton ppfr je suis obligé de fermer l'éxécution et de refaire play pour cliquer sur mon second bouton ppfm
      je ne comprends pas pourquoi ça me fait ça
      pensez vous pouvoir m'aider???
      MON PROJET
      Module de données
      Option Strict On
      Module Module1
      'Données globales propre à l'interface
      'Type pour la liste des candidats
      Public Structure Candidat
      Dim NomAbrégé As String
      Dim NomComplet As String
      Dim NVi As Integer
      Dim NbSiegesObtenus As Integer
      Dim NbSiegesObtenusTour2 As Integer
      End Structure
      Public Liste(0 To 20) As Candidat
      Public nbCandidat As Integer
      Public NStotal As Integer
      Public NVtotal As Integer
      Public Const maxCandidat = 20
      'Données globales propre à l'interface
      Public Enum NatureAjout
      modification
      création
      End Enum
      Public typeAjout As NatureAjout 'indique si on ajoute ou si on modifie un candidat

      Public indiceCandidatSelection As Integer 'indique l'indice du candidat sélectionné (-1 si pas de sélection)

      Public Sub ListedeBase()
      nbCandidat = 4

      Liste(0).NomAbrégé = "PS"
      Liste(0).NomComplet = "Parti Socialiste"
      Liste(0).NVi = 214000
      Liste(0).NbSiegesObtenus = 0

      Liste(1).NomAbrégé = "UMP"
      Liste(1).NomComplet = "Union pour la Majorité Présidentielle"
      Liste(1).NVi = 99000
      Liste(1).NbSiegesObtenus = 0

      Liste(2).NomAbrégé = "PC"
      Liste(2).NomComplet = "Parti Communiste"
      Liste(2).NVi = 66000
      Liste(2).NbSiegesObtenus = 0

      Liste(3).NomAbrégé = "MODEM"
      Liste(3).NomComplet = "Mouvement Démocrate"
      Liste(3).NVi = 21000
      Liste(3).NbSiegesObtenus = 0
      End Sub
      End Module

      Module de traitements
      Option Strict On
      Module Module2

      Public Function RechercheCandidat(ByVal NomAbrégé As String, ByVal NomComplet As String) As Integer
      'Vérifie que la liste n'est pas déjà présente
      Dim i As Integer
      For i = 0 To nbCandidat
      If Liste(i).NomAbrégé = NomAbrégé And Liste(i).NomComplet = NomComplet Then
      Return i
      End If
      Next
      Return -1
      End Function
      Public Sub AjouterCandidat(ByVal c As Candidat)
      If nbCandidat < maxCandidat And RechercheCandidat(c.NomAbrégé, c.NomComplet) = -1 Then
      Liste(nbCandidat) = c
      nbCandidat = nbCandidat + 1
      End If
      End Sub
      Public Function CandidatToString(ByVal c As Candidat) As String
      'transforme un candidat en chaîne de caractères
      Dim s As String
      s = ""
      'nom abrégée
      s = s + c.NomAbrégé
      Return s
      End Function
      Public Function CandidatToStringTour1(ByVal c As Candidat) As String
      'renvoie les informations utile une fois le premier tour effectué
      Dim s As String
      s = c.NomComplet + ", sièges obtenus :" + " " + CStr(c.NbSiegesObtenus)
      Return s
      End Function
      Public Function CandidatToStringTour2(ByVal c As Candidat) As String
      'renvoie les informations utile une fois le second tour effectué
      Dim s As String
      s = c.NomComplet + ", sièges obtenus au 2nd tour : " + CStr(c.NbSiegesObtenusTour2) + ", Total des sièges obtenus : " + CStr(c.NbSiegesObtenus)
      Return s
      End Function
      Public Sub supprimer(ByVal NumListe As Integer)
      If NumListe >= 0 And NumListe < nbCandidat Then
      Liste(NumListe) = Liste(nbCandidat - 1) 'on remplace la liste à supprimer par la dernière du tableau
      nbCandidat = nbCandidat - 1
      End If
      End Sub
      Public Sub modifierNomAbrégé(ByRef c As Candidat, ByVal NomAbrégé As String)
      c.NomAbrégé = NomAbrégé
      End Sub
      Public Sub modifierNomComplet(ByRef c As Candidat, ByVal NomComplet As String)
      c.NomComplet = NomComplet
      End Sub
      Public Sub modifierNVi(ByVal NVi As Integer, ByRef c As Candidat)
      c.NVi = NVi
      End Sub
      Public Function QuotientElectoral(ByVal NS As Integer) As Integer
      'Fonction permettant de calculer le quotient électoral
      Dim QE As Integer
      NVtotal = NbVotesTotal(Liste)
      If NS <> 0 Then
      QE = CInt(Fix(NVtotal / NS))
      End If
      Return QE
      End Function
      Public Sub Tour1(ByVal NS As Integer)
      'Calcule les sièges obtenus au 1er tour
      Dim NSi As Integer
      Dim i As Integer
      Dim QE As Integer
      NStotal = 0
      QE = QuotientElectoral(NS)
      For i = 0 To nbCandidat - 1
      'parcourt tout le tableau ou figure les listes
      If QE <> 0 Then
      NSi = CInt(Fix(Liste(i).NVi / QE))
      Liste(i).NbSiegesObtenus = NSi
      NStotal = NStotal + NSi
      End If
      Next
      End Sub
      Public Function NbVotesTotal(ByVal liste() As Candidat) As Integer
      'calcul le nombre de votes total
      Dim NVtotal As Integer
      For i = 0 To nbCandidat - 1
      NVtotal = NVtotal + liste(i).NVi
      Next
      Return NVtotal
      End Function
      Public Sub Tour2PPFR(ByVal NS As Integer, ByVal QE As Integer)
      Dim QE2 As Integer
      Dim NS2 As Integer
      QE2 = CInt(Fix(NbVotesTotal(Liste) - (NStotal * QE) / NS - NStotal))
      For i = 0 To nbCandidat - 1
      If QE2 <> 0 Then
      NS2 = CInt(Fix((Liste(i).NVi - Liste(i).NbSiegesObtenus * QE) / QE2))
      Liste(i).NVi = Liste(i).NVi - (Liste(i).NbSiegesObtenus * QE) - (Liste(i).NbSiegesObtenusTour2 * QE2) 'permet de stocker le nombre de voix restantes pour la liste i
      Liste(i).NbSiegesObtenus = Liste(i).NbSiegesObtenus + NS2
      Liste(i).NbSiegesObtenusTour2 = NS2
      NStotal = NStotal + NS2
      End If
      Next
      End Sub
      Public Function NbVoixRestantes(ByVal liste As Candidat, ByVal QE As Integer) As Integer
      'Calcule le nombre de voix restantes pour une liste donnée
      Dim NbVoixRest As Integer
      NbVoixRest = liste.NVi - liste.NbSiegesObtenus * QE
      Return NbVoixRest
      End Function
      Public Function maxVoixRestantes(ByVal Liste() As Candidat) As Integer
      'permet de retourner l'indice de la liste qui possède le plus de voix restantes
      Dim max As Integer
      Dim maxi As Integer
      max = -1
      maxi = -1
      For i = 0 To nbCandidat - 1
      If Liste(i).NVi > max Then
      max = Liste(i).NVi
      maxi = i
      End If
      Next
      Return maxi
      End Function
      Public Sub EnCasdEgalité(ByVal NS As Integer)
      Dim NSRest As Integer
      NSRest = NS - NStotal
      While NSRest <> 0
      Liste(maxVoixRestantes(Liste)).NbSiegesObtenusTour2 = Liste(maxVoixRestantes(Liste)).NbSiegesObtenusTour2 + 1
      Liste(maxVoixRestantes(Liste)).NbSiegesObtenus = Liste(maxVoixRestantes(Liste)).NbSiegesObtenus + 1
      Liste(maxVoixRestantes(Liste)).NVi = 0
      NSRest = NSRest - 1
      End While
      End Sub
      Public Function NRmaxPPFM(ByVal liste() As Candidat) As Integer
      'retourne l'indice de la liste ayant le plus grand nombre de voix restantes selon le mode de scrutin PPFM
      Dim i As Integer
      Dim max As Integer
      Dim maxi As Integer
      max = -1
      maxi = -1
      For i = 0 To nbCandidat - 1
      If CInt(Fix(liste(i).NVi / ((liste(i).NbSiegesObtenus) + 1))) > max Then
      max = CInt(Fix(liste(i).NVi / ((liste(i).NbSiegesObtenus) + 1)))
      maxi = i
      End If
      Next
      Return maxi
      End Function

      Public Sub Tour2PPFM(ByVal NS As Integer)
      Dim i As Integer
      Dim NSRest As Integer
      NSRest = NS - NStotal
      For i = 0 To nbCandidat - 1
      Liste(i).NbSiegesObtenusTour2 = 0
      Next
      For i = 1 To NSRest
      Liste(NRmaxPPFM(Liste)).NbSiegesObtenusTour2 = Liste(NRmaxPPFM(Liste)).NbSiegesObtenusTour2 + 1
      Liste(NRmaxPPFM(Liste)).NbSiegesObtenus = Liste(NRmaxPPFM(Liste)).NbSiegesObtenus + 1
      Next
      End Sub

      End Module

      FEUILLE PRINCIPALE

      Option Strict On
      Public Class aform_princ
      Dim NS As Integer
      Private Sub txt_NS_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txt_NS.TextChanged
      NS = CInt(Val(txt_NS.Text))
      End Sub
      Private Sub aform_princ_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      'chargement de l'application
      'initialisation des données et affichage
      Call ListedeBase()
      Call afficherListe()

      'désactiver les boutons
      btn_ajouter.Enabled = False
      btn_modif.Enabled = False

      btn_suppr.Enabled = False

      'activer les boutons
      btn_ajouter.Enabled = True
      End Sub
      Public Sub effacerInfosCandidats()
      lbl_NomC.Text = ""
      lbl_NVi.Text = ""
      btn_suppr.Enabled = False
      btn_modif.Enabled = False
      btn_ppfm.Enabled = False
      btn_ppfr.Enabled = False
      End Sub
      Private Sub afficherInfosListe(ByVal c As Candidat)
      'affiche les données d'une liste
      lbl_NomC.Text = c.NomComplet
      lbl_NVi.Text = CStr(c.NVi)
      'activation des boutons
      btn_suppr.Enabled = True
      btn_modif.Enabled = True
      btn_ppfr.Enabled = True
      btn_ppfm.Enabled = True
      'lst_tour1.Text = ""
      'lst_tour2.Text = ""
      End Sub
      Public Sub afficherListe()
      'affiche le contenu de la liste dans la listbox
      'efface la listebox avant de la remplir
      lst_candidats.Items.Clear()
      'remplir la listbox
      Dim i As Integer
      For i = 0 To nbCandidat - 1
      lst_candidats.Items.Add(CandidatToString(Liste(i)))
      Next
      'afficher les informations de la liste si nécessaire
      If indiceCandidatSelection <> -1 Then
      Call afficherInfosListe(Liste(indiceCandidatSelection))
      Else
      Call effacerInfosCandidats()
      End If
      End Sub
      Private Sub lst_candidats_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lst_candidats.SelectedIndexChanged
      indiceCandidatSelection = lst_candidats.SelectedIndex
      If indiceCandidatSelection <> -1 Then
      Call afficherInfosListe(Liste(indiceCandidatSelection))
      Else
      Call effacerInfosCandidats()
      End If
      If Form_ajout.Visible = True Then
      Call Form_ajout.refreshInfos()
      End If
      End Sub
      Private Sub afficher(ByVal liste() As Candidat, ByVal tailleT As Integer)
      Dim i As Integer
      Dim s As String
      s = ""
      lst_tour1.Items.Clear() 'Effacer la Listbox

      For i = 0 To tailleT - 1
      s = CStr(lst_tour1.Items.Add(CandidatToString(liste(i))) + lst_tour1.Items.Add(NStotal))
      Next
      End Sub
      Private Sub btn_ppfr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ppfr.Click
      lbl_QE.Text = CStr(QuotientElectoral(NS))
      Call Tour1(NS)
      Call afficherListeTour1()
      If NStotal < NS Then
      Call Tour2PPFR(NS, QuotientElectoral(NS))
      End If
      If NStotal < NS Then
      Call EnCasdEgalité(NS)
      End If
      Call afficherListeTour2()
      End Sub
      Private Sub btn_ppfm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ppfm.Click
      lbl_QE.Text = CStr(QuotientElectoral(NS))
      Call Tour1(NS)
      Call afficherListeTour1()
      If NStotal < NS Then
      Call Tour2PPFM(NS)
      End If
      If NStotal < NS Then
      Call EnCasdEgalité(NS)
      End If
      Call afficherListeTour2()
      End Sub
      Private Sub btn_suppr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_suppr.Click
      If indiceCandidatSelection <> -1 Then
      Call supprimer(indiceCandidatSelection)
      Call effacerInfosCandidats()
      Call afficherListe()
      End If
      End Sub
      Private Sub btn_modif_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_modif.Click
      If indiceCandidatSelection <> -1 Then
      typeAjout = NatureAjout.modification
      If Form_ajout.Visible = False Then
      Form_ajout.Show() 'permet d'ouvrir la fenêtre si elle n'est pas ouverte
      End If
      Call Form_ajout.refreshInfos()
      End If
      End Sub
      Private Sub btn_ajouter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ajouter.Click
      indiceCandidatSelection = -1
      typeAjout = NatureAjout.création
      If Form_ajout.Visible = False Then
      Form_ajout.Show() 'permet d'ouvrir la fenêtre si elle n'est pas ouverte
      End If
      Call Form_ajout.refreshInfos()
      End Sub
      Public Sub afficherListeTour1()
      'permet de remplir la listebox avec les résultats du 1er tour
      lst_tour1.Items.Clear()
      Dim i As Integer
      For i = 0 To nbCandidat - 1
      lst_tour1.Items.Add(CandidatToStringTour1(Liste(i)))
      Next
      End Sub
      Public Sub afficherListeTour2()
      'permet de remplir la listebox avec les résultats du 2nd tour
      lst_tour2.Items.Clear()
      Dim i As Integer
      For i = 0 To nbCandidat - 1
      lst_tour2.Items.Add(CandidatToStringTour2(Liste(i)))
      Next
      End Sub
      End Class

      SECONDE FEUILLE

      Option Strict On
      Public Class Form_ajout
      Private Sub afficherInfosListe(ByVal c As Candidat)
      'permet d'affichier les données dans les labels de la feuille principale
      txt_NomAb.Text = c.NomAbrégé
      txt_NomCo.Text = c.NomComplet
      txt_NVi.Text = CStr(c.NVi)
      btn_valider.Enabled = True
      End Sub
      Private Sub effaceInfosCandidats()
      txt_NomAb.Text = ""
      txt_NomCo.Text = ""
      txt_NVi.Text = CStr(0)
      btn_valider.Enabled = True
      End Sub
      Public Sub refreshInfos()
      If typeAjout = NatureAjout.création Then
      Call effaceInfosCandidats()
      ElseIf typeAjout = NatureAjout.modification And indiceCandidatSelection <> -1 Then
      Call afficherInfosListe(Liste(indiceCandidatSelection))
      End If
      End Sub
      Private Sub Form_ajout_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
      Call refreshInfos()
      End Sub
      Private Sub btn_valider_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_valider.Click
      Dim c As Candidat
      If typeAjout = NatureAjout.création Then
      If txt_NomAb.Text <> "" And txt_NomCo.Text <> "" Then
      c.NomComplet = txt_NomCo.Text
      c.NomAbrégé = txt_NomAb.Text
      c.NVi = CInt(txt_NVi.Text)
      'si ces conditions sont vérifées alors on peut rajouter une liste
      Call AjouterCandidat(c) 'indice de la dernière liste ajouter = nbListes - 1
      End If
      ElseIf typeAjout = NatureAjout.modification Then
      Call modifierNomAbrégé(Liste(indiceCandidatSelection), txt_NomAb.Text)
      Call modifierNomComplet(Liste(indiceCandidatSelection), txt_NomCo.Text)
      Call modifierNVi(CInt(txt_NVi.Text), Liste(indiceCandidatSelection))
      End If

      'rafraichir affichage apres ajout et modification
      Call aform_princ.afficherListe()
      'par sécurité..
      indiceCandidatSelection = -1
      'fermer la fenêtre
      Close()
      End Sub
      End Class

      merci d'avance
      1. je me permet de commenter ton code.
        - si tu ajoutes "Option Strict On" tout en haut de tes classes et modules tu te rendras compte de plrs erreurs ex. Fix est une fonction qui retourne un double et non un entier même si c'est la partie entière.

        - au lieu de Dim NSrestant As Integer
        NSrestant = NS - NStotal

        Dim NSrestant As Integer = NS - NStotal c'est plus simple

        - fais attention aux divisions / 0 dans tes fonctions

        bon courage
        1. merci beaucoup
          L'Option Strict On m'a en effet corrigé pas mal d'erreur; merci pour l'astuce.
          Maintenant me reste à relier mes boutons ppfr et ppfm et je vais peut etre enfin en voir la fin
      2. Merci beaucoup
        En fait j'ai trouvé, j'ai fais un reglement ds les parametres. Le logiciel considérait la seconde feuille comme feuille principale.
        Merci d'avoir pris le temps regarder pour m'aider.
        Bonne fin de journée
        1. Contributeur
          OK,
          J'ai pas tout lu mais je vois que tu initialise une listbox, ton problème vient probablement de là.
          Si, par exemple, tu met ListBox1.listIndex = 0... ça va envoyer dans l'événement ListBox1.Change, ou click.
          Le moyen de l'éviter (c'est toujours ce que je fais)..
          Une variable boolean public, déclarée dans le haut du module.
          Et avant d'initialiser la ListBox je met VarBoolean = True
          Et das l'événement Change ou click de ListBox je met en première ligne..
          If VarBoolean then exit sub.

          Pas oublier de remettre VarBoolean = False juste après.
          C'est valable aussi pour un ComboBox, TextBox, enfin tout ce qui à un événement change ou click.
          A+
          L'expérience instruit plus sûrement que le conseil. (André Gide)
          Si tu te cognes à un pot et que ça sonne creux, c'est pas forcément le pot qui est vide. ;-)(Confucius)
          1. Je vous montre également le module de données
            et celui de traitements
            Module Module1
            'Données globales propre à l'interface
            'Type pour la liste des candidats
            Public Structure Candidat
            Dim NomAbrégé As String
            Dim NomComplet As String
            Dim NVi As Integer
            Dim NbSiegesObtenus As Integer
            Dim NbSiegesObtenusTour2 As Integer
            End Structure
            Public Liste(0 To 20) As Candidat
            Public nbCandidat As Integer
            Public NStotal As Integer
            Public NVtotal As Integer
            Public Const maxCandidat = 20
            'Données globales propre à l'interface
            Public Enum NatureAjout
            modification
            création
            End Enum
            Public typeAjout As NatureAjout 'indique si on ajoute ou si on modifie un candidat

            Public indiceCandidatSelection As Integer 'indique l'indice du candidat sélectionné (-1 si pas de sélection)

            Public Sub ListedeBase()
            nbCandidat = 4

            Liste(0).NomAbrégé = "PS"
            Liste(0).NomComplet = "Parti Socialiste"
            Liste(0).NVi = 1000
            Liste(0).NbSiegesObtenus = 0

            Liste(1).NomAbrégé = "UMP"
            Liste(1).NomComplet = "Union pour la Majorité Présidentielle"
            Liste(1).NVi = 2000
            Liste(1).NbSiegesObtenus = 0

            Liste(2).NomAbrégé = "PC"
            Liste(2).NomComplet = "Parti Communiste"
            Liste(2).NVi = 200
            Liste(2).NbSiegesObtenus = 0

            Liste(3).NomAbrégé = "MODEM"
            Liste(3).NomComplet = "Mouvement Démocrate"
            Liste(3).NVi = 700
            Liste(3).NbSiegesObtenus = 0
            End Sub

            End Module

            Module Module2
            'Vérifie que la liste n'est pas déjà présente
            Public Function RechercheCandidat(ByVal NomAbrégé As String, ByVal NomComplet As String) As Integer
            Dim i As Integer
            For i = 0 To nbCandidat
            If Liste(i).NomAbrégé = NomAbrégé And Liste(i).NomComplet = NomComplet Then
            Return i
            End If
            Next
            Return -1
            End Function
            Public Sub AjouterCandidat(ByVal c As Candidat)
            If nbCandidat < maxCandidat And RechercheCandidat(c.NomAbrégé, c.NomComplet) = -1 Then
            Liste(nbCandidat) = c
            nbCandidat = nbCandidat + 1
            End If
            End Sub
            Public Function CandidatToString(ByVal c As Candidat) As String
            'transforme un candidat en chaîne de caractères
            Dim s As String
            s = ""

            'nom abrégée
            s = s + c.NomAbrégé
            Return s
            End Function
            Public Sub supprimer(ByVal NumListe As Integer)
            If NumListe >= 0 And NumListe < nbCandidat Then
            Liste(NumListe) = Liste(nbCandidat - 1) 'on remplace la liste à supprimer par la dernière du tableau
            nbCandidat = nbCandidat - 1
            End If
            End Sub
            Public Sub modifierNomAbrégé(ByRef c As Candidat, ByVal NomAbrégé As String)
            c.NomAbrégé = NomAbrégé
            End Sub
            Public Sub modifierNomComplet(ByRef c As Candidat, ByVal NomComplet As String)
            c.NomComplet = NomComplet
            End Sub
            Public Sub modifierNVi(ByVal NVi As Integer, ByRef c As Candidat)
            c.NVi = NVi
            End Sub
            'Fonction permettant de calculer le quotient électoral
            Public Function QuotientElectoral(ByVal NV As Integer, ByVal NS As Integer) As Integer
            Dim QE As Integer
            QE = Fix(NV / NS)
            Return QE
            End Function
            Public Sub Tour1(ByVal NS As Integer, ByVal Listes() As Candidat, ByRef NStotal As Integer)
            'Calcule les sièges obtenus au 1er tour
            Dim NSi As Integer
            Dim i As Integer
            Dim QE As Integer
            NStotal = 0
            QE = QuotientElectoral(NbVotesTotal(Listes), NS)
            For i = 0 To nbCandidat - 1
            'parcourt tout le tableau ou figure les listes
            NSi = Fix(Liste(i).NVi / QE)
            Liste(i).NbSiegesObtenus = NSi
            NStotal = NStotal + NSi
            Next
            End Sub
            Public Function NbVotesTotal(ByVal liste() As Candidat) As Integer
            'calcul le nombre de votes total
            Dim NVtotal As Integer
            For i = 0 To nbCandidat - 1
            NVtotal = NVtotal + liste(i).NVi
            Next
            Return NVtotal
            End Function
            Public Sub Tour2PPFR(ByVal NS As Integer, ByVal NStotal As Integer, ByVal QE As Integer)
            Dim QE2 As Integer
            Dim NS2 As Integer
            QE2 = QuotientElectoral(NbVotesTotal(Liste) - NStotal * QE, NS - NStotal)
            For i = 0 To nbCandidat - 1
            NS2 = Fix((Liste(i).NVi - Liste(i).NbSiegesObtenus * QE) / QE2)
            Liste(i).NbSiegesObtenus = Liste(i).NbSiegesObtenus + NS2
            Liste(i).NbSiegesObtenusTour2 = NS2
            Next
            End Sub
            Public Function NbVoixRestantes(ByVal liste As Candidat, ByVal QE As Integer) As Integer
            'Calcule le nombre de voix restantes pour une liste donnée
            Dim NbVoixRest As Integer
            NbVoixRest = liste.NVi - liste.NbSiegesObtenus * QE
            Return NbVoixRest
            End Function
            Public Function maxVoixRestantes(ByVal tab() As Candidat, ByVal QE As Integer) As Integer
            'permet de retourner l'indice de la liste qui possède le plus de voix restantes
            Dim max As Integer
            Dim maxi As Integer
            max = -1
            maxi = -1
            For i = 0 To nbCandidat - 1
            If NbVoixRestantes(Liste(i), QE) > max Then
            max = NbVoixRestantes(Liste(i), QE)
            maxi = i
            End If
            Next
            Return maxi
            End Function
            Public Sub EnCasdEgalité(ByVal NStotal As Integer, ByVal NbSiegesTour1 As Integer, ByVal liste() As Candidat, ByVal QE As Integer)
            Dim NbSRest As Integer
            NbSRest = NStotal - NbSiegesTour1
            For i = 0 To nbCandidat - 1
            liste(i).NbSiegesObtenusTour2 = 0
            Next
            While NbSRest <> 0
            liste(maxVoixRestantes(liste, QE)).NbSiegesObtenusTour2 = liste(maxVoixRestantes(liste, QE)).NbSiegesObtenusTour2 + 1
            NbSRest = NbSRest - 1
            End While
            End Sub
            Public Function NRmaxPPFM(ByVal liste() As Candidat) As Integer
            'retourne l'indice de la liste ayant le plus grand nombre de voix restantes selon le mode de scrutin PPFM
            Dim i As Integer
            Dim NR As Integer
            Dim max As Integer
            Dim maxi As Integer
            max = -1
            maxi = -1
            For i = 0 To nbCandidat - 1
            NR = Fix(liste(i).NVi / (liste(i).NbSiegesObtenus + 1))
            If NR > max Then
            max = NR
            maxi = i
            End If
            Next
            Return maxi
            End Function
            Public Sub Tour2PPFM(ByVal liste() As Candidat, ByVal NS As Integer, ByRef NStotal As Integer)
            Dim i As Integer
            Dim NSrestant As Integer
            NSrestant = NS - NStotal
            For i = 0 To nbCandidat - 1
            liste(i).NbSiegesObtenusTour2 = 0
            Next
            While NSrestant <> 0
            liste(NRmaxPPFM(liste)).NbSiegesObtenusTour2 = liste(NRmaxPPFM(liste)).NbSiegesObtenusTour2 + 1
            liste(NRmaxPPFM(liste)).NbSiegesObtenus = liste(NRmaxPPFM(liste)).NbSiegesObtenus + 1
            End While
            End Sub

            End Module
            1. Voici mon form load de ma feuille principale
              Public Class aform_princ
              Private Sub aform_princ_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
              'chargement de l'application
              'initialisation des données et affichage
              Call ListedeBase()
              Call afficherListe()

              'désactiver les boutons
              btn_ajouter.Enabled = False
              btn_modif.Enabled = False
              btn_ppfr.Enabled = False
              btn_ppfm.Enabled = False
              btn_suppr.Enabled = False

              'activer les boutons
              btn_ajouter.Enabled = True
              End Sub
              Public Sub effacerInfosCandidats()
              lbl_NomC.Text = ""
              lbl_NVi.Text = ""
              btn_suppr.Enabled = False
              btn_modif.Enabled = False
              btn_ppfm.Enabled = False
              btn_ppfr.Enabled = False
              End Sub
              Private Sub afficherInfosListe(ByVal c As Candidat)
              'affiche les données d'une liste
              lbl_NomC.Text = c.NomComplet
              lbl_NVi.Text = c.NVi
              'activation des boutons
              btn_suppr.Enabled = True
              btn_modif.Enabled = True
              btn_ppfr.Enabled = True
              btn_ppfm.Enabled = True
              'lst_tour1.Text = ""
              'lst_tour2.Text = ""
              End Sub
              Public Sub afficherListe()
              'affiche le contenu de la liste dans la listbox
              'efface la listebox avant de la remplir
              lst_candidats.Items.Clear()
              'remplir la listbox
              Dim i As Integer
              For i = 0 To nbCandidat - 1
              lst_candidats.Items.Add(CandidatToString(Liste(i)))
              Next
              'afficher les informations de la liste si nécessaire
              If indiceCandidatSelection <> -1 Then
              Call afficherInfosListe(Liste(indiceCandidatSelection))
              Else
              Call effacerInfosCandidats()
              End If
              End Sub
              Private Sub lst_candidats_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lst_candidats.SelectedIndexChanged
              indiceCandidatSelection = lst_candidats.SelectedIndex
              If indiceCandidatSelection <> -1 Then
              Call afficherInfosListe(Liste(indiceCandidatSelection))
              Else
              Call effacerInfosCandidats()
              End If
              If Form_ajout.Visible = True Then
              Call Form_ajout.refreshInfos()
              End If
              End Sub
              Private Sub btn_ppfr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ppfr.Click
              Call Tour1(Val(txt_NS.Text), Liste, NStotal)
              End Sub
              Private Sub btn_ppfm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ppfm.Click

              End Sub
              Private Sub btn_suppr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_suppr.Click
              If indiceCandidatSelection <> -1 Then
              Call supprimer(indiceCandidatSelection)
              Call effacerInfosCandidats()
              Call afficherListe()
              End If
              End Sub
              Private Sub btn_modif_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_modif.Click
              If indiceCandidatSelection <> -1 Then
              typeAjout = NatureAjout.modification
              If Form_ajout.Visible = False Then
              Form_ajout.Show() 'permet d'ouvrir la fenêtre si elle n'est pas ouverte
              End If
              Call Form_ajout.refreshInfos()
              End If
              End Sub
              Private Sub btn_ajouter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ajouter.Click
              indiceCandidatSelection = -1
              typeAjout = NatureAjout.création
              If Form_ajout.Visible = False Then
              Form_ajout.Show() 'permet d'ouvrir la fenêtre si elle n'est pas ouverte
              End If
              Call Form_ajout.refreshInfos()
              End Sub
              End Class

              voici le form load de ma seconde feuille
              Public Class Form_ajout
              Private Sub afficherInfosListe(ByVal c As Candidat)
              'permet d'affichier les données dans les labels de la feuille principale
              txt_NomAb.Text = c.NomAbrégé
              txt_NomCo.Text = c.NomComplet
              txt_NVi.Text = c.NVi
              btn_valider.Enabled = True
              End Sub
              Private Sub effaceInfosCandidats()
              txt_NomAb.Text = ""
              txt_NomCo.Text = ""
              txt_NVi.Text = 0
              btn_valider.Enabled = True
              End Sub
              Public Sub refreshInfos()
              If typeAjout = NatureAjout.création Then
              Call effaceInfosCandidats()
              ElseIf typeAjout = NatureAjout.modification And indiceCandidatSelection <> -1 Then
              Call afficherInfosListe(Liste(indiceCandidatSelection))
              End If
              End Sub
              Private Sub Form_ajout_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
              Call refreshInfos()
              End Sub
              Private Sub btn_valider_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_valider.Click
              Dim c As Candidat
              If typeAjout = NatureAjout.création Then
              If txt_NomAb.Text <> "" And txt_NomCo.Text <> "" Then
              c.NomComplet = txt_NomCo.Text
              c.NomAbrégé = txt_NomAb.Text
              c.NVi = txt_NVi.Text
              'si ces conditions sont vérifées alors on peut rajouter une liste
              Call AjouterCandidat(c) 'indice de la dernière liste ajouter = nbListes - 1
              End If
              ElseIf typeAjout = NatureAjout.modification Then
              Call modifierNomAbrégé(Liste(indiceCandidatSelection), txt_NomAb.Text)
              Call modifierNomComplet(Liste(indiceCandidatSelection), txt_NomCo.Text)
              Call modifierNVi(txt_NVi.Text, Liste(indiceCandidatSelection))
              End If

              'rafraichir affichage apres ajout et modification
              Call aform_princ.afficherListe()
              'par sécurité..
              indiceCandidatSelection = -1
              'fermer la fenêtre
              Close()
              End Sub
              End Class
              1. Contributeur
                Bonjour,
                Tu peu montrer le code que tu a dans Form_Load ?
                A+