Private Sub connection_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing If Me.Visible = True Then e.Cancel = Fermeture(Me) End If End Sub Private Sub Linscription_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles Linscription.LinkClicked Me.Visible = False Inscription.Show() Me.Close() End Sub
Private Sub Fermeture(ByVal fr As Form) If MessageBox.Show("Voulez-vous quitter " & fr.Name, ".:: DEMANDE", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then fr.Close() Else Exit Sub End If End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Sub connection_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing Fermeture(Me) End Sub
Private Sub connection_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing If Fermeture(Me) Then e.Cancel = True End If End Sub
Public Function Fermeture(ByVal fr As Form) If MessageBox.Show("Voulez-vous quitter " & fr.Name, ".:: DEMANDE", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then Return False Else Return True End If End Function
connection_FormClosing?
Private Sub Linscription_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles Linscription.LinkClicked Inscription.Show() Me.Close() End Sub
'Message personnalisé de chaque form Public Function Fermeture(ByVal fr As Form) If MessageBox.Show("Voulez-vous quitter " & fr.Name, ".:: DEMANDE", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then Return False Else Return True End If End Function
Private Sub connection_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing If Fermeture(Me) Then e.Cancel = True End If End Sub
Module fonction '--------- B D D ---------------- 'renvoie l'emplacement où se trouve la BD Public Function createChemin() As String Dim chemin As String Dim dbname As String = "Data_base" Dim cheminApp As String = Application.StartupPath cheminApp &= "" chemin = cheminApp & dbname & ".accdb" 'MessageBox.Show(chemin) Return chemin End Function 'Test si un fichier existe ' dans ce cas-là, test si la base existe à l'aide de son chemin Public Function ExistBase() As Boolean Return System.IO.File.Exists(createChemin()) End Function '--------- FORMULAIRE ----------- 'Message personnalisé de chaque form Public Function Fermeture(ByVal fr As Form) Return Not (MessageBox.Show("Voulez-vous quitter " & fr.Name, ".:: DEMANDE", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes) End Function 'Affichage en fonction du formulaire Public Sub Affichage(ByVal fr As Form, ByVal gb As GroupBox) Select Case fr.Name Case "connection" AffichageConnection(gb) End Select End Sub 'Affiche ou pas les ctrl de la page Connection Private Sub AffichageConnection(ByVal gb As GroupBox) For Each ctrl In gb.Controls ctrl.Enabled = False If ctrl.Name = "Linscription" Then ctrl.Enabled = True End If Next End Sub 'vérifie si TextBox vide Private Function TBvide(ByVal tb As TextBox) As Boolean 'return true si vide Return tb.Text = "" End Function 'vérifie si ComboBox vide Private Function CBvide(ByVal cb As ComboBox) As Boolean 'return true si vide Return cb.SelectedText = "" End Function 'Parcours controls dans un GroupBox Public Sub Verif_Ctrl(ByVal gb As GroupBox, ByRef ep As ErrorProvider) 'Pour chaque CTRL dans le GroupBox For Each ctrl In gb.Controls 'Si le type est TextBox If TypeOf ctrl Is TextBox Then 'Si fonction TBvide = true If TBvide(ctrl) Then ep.SetError(ctrl, "Champ " & ctrl.name & " vide !") End If 'Si le type est ComboBox ElseIf TypeOf ctrl Is ComboBox Then 'Si fonction TBvide = true If CBvide(ctrl) Then ep.SetError(ctrl, "Sélection " & ctrl.name & " vide !") End If End If Next End Sub End Module