Generateur de messages boxs

Description

Un petit programme tres simple que je compte bien ameliorer en un multi boxs generator
tous est dans le zip g quand meme mis le code mais bon vu le nombre de controles qu'il y a vous aurez du mal a la faire fonctioner sans telecharger le zip,
le code parait long mais c la meme chose c juste le nom de controle qui change

Source / Exemple :


Option Explicit
Dim v1, v2, v3, v4, v5, Title1, Picture1, Buton, v6, v7, v8, v9, v10, Title2, Pictur2, M As Integer
Private Sub Check1_Click()
If Check1.Value = 1 Then
Check1.Caption = "Beep On"
ElseIf Check1.Value = 0 Then
Check1.Caption = "Beep Off"
End If
End Sub
Private Sub Check2_Click()
If Check2.Value = 1 Then
Check2.Caption = "Masquer On"
ElseIf Check1.Value = 0 Then
Check2.Caption = "Masquer Off"
End If
End Sub
Private Sub form_load()
Option1(0).Value = True
Option3(2).Value = True
Option2(0).Value = True
End Sub
Private Sub Form_unload(cancel As Integer)
End
End Sub
Private Sub Command3_Click()
Unload Me
End Sub

'generation de la msgbox
Private Sub Command1_Click()

If Option1(0).Value = True Then
Picture1 = vbQuestion
End If
If Option1(1).Value = True Then
Picture1 = vbInformation
End If
If Option1(2).Value = True Then
Picture1 = vbExclamation
End If
If Option1(3).Value = True Then
Picture1 = vbCritical
End If

If Option3(0).Value = True Then
Buton = vbYesNo
End If
If Option3(1).Value = True Then
Buton = vbYesNoCancel
End If
If Option3(2).Value = True Then
Buton = vbOKOnly
End If
If Option3(3).Value = True Then
Buton = vbOKCancel
End If
If Option3(5).Value = True Then
Buton = vbRetryCancel
End If
If Option3(6).Value = True Then
Buton = vbAbortRetryIgnore
End If
If Not Text1.Text = "" Then
Title1 = Text1.Text
End If

If Not Text2.Text = "" Then
v1 = Text2.Text & Chr(10)
ElseIf Text2.Text = "Ligne 1" Then
v1 = ""
Else
Resume Next
End If

If Not Text3.Text = "" Then
v2 = Text3.Text & Chr(10)
ElseIf Text3.Text = "Ligne 2" Then
v2 = ""
Else
Resume Next
End If

If Not Text4.Text = "" Then
v3 = Text4.Text & Chr(10)
ElseIf Text4.Text = "Ligne 3" Then
v3 = ""
Else
Resume Next
End If

If Not Text5.Text = "" Then
v4 = Text5.Text & Chr(10)
ElseIf Text5.Text = "Ligne 4" Then
v4 = ""
Else
Resume Next
End If

If Not Text6.Text = "" Then
v5 = Text6.Text
ElseIf Text6.Text = "Ligne 5" Then
v5 = ""
Else
Resume Next
End If
If Not Text1.Text = "" Then
If Not Text1.Text = "Titre" Then
If Not Text2.Text = "Ligne 1" Then
    If Not Text3.Text = "Ligne 2" Then
        If Not Text4.Text = "Ligne 3" Then
            If Not Text5.Text = "Ligne 4" Then
                If Not Text6.Text = "Ligne 5" Then
msg0:
                Call mask
                Call bep
                M = MsgBox(v1 & v2 & v3 & v4 & v5, Buton + Picture1, Title1)
                If M = vbRetry Then
                GoTo msg0
                End If
                Me.Visible = True
                Exit Sub
                End If
msg1:
            Call mask
            Call bep
            M = MsgBox(v1 & v2 & v3 & v4, Buton + Picture1, Title1)
            If M = vbRetry Then
            GoTo msg1
            End If
            Me.Visible = True
            Exit Sub
            End If
msg2:
        Call mask
        Call bep
        M = MsgBox(v1 & v2 & v3, Buton + Picture1, Title1)
        If M = vbRetry Then
        GoTo msg2
        End If
        Me.Visible = True
        Exit Sub
        End If
msg3:
    Call mask
    Call bep
    M = MsgBox(v1 & v2, Buton + Picture1, Title1)
    If M = vbRetry Then
    GoTo msg3
    End If
    Me.Visible = True
    Exit Sub
    End If
msg4:
Call mask
Call bep
M = MsgBox(v1, Buton + Picture1, Title1)
Me.Visible = True
If M = vbRetry Then
GoTo msg4
End If
Exit Sub
End If
Me.Visible = True
MsgBox "Vous devez paramètrer le reste de la boite de dialogue !!", vbOKOnly + vbCritical, "Attention"
Me.Visible = True
Exit Sub
Else
Me.Visible = True
MsgBox "Vous devez ecrire un titre pour votre boite de dialogue !!", vbOKOnly + vbCritical, "Attention"
Me.Visible = True
Exit Sub
End If
Me.Visible = True
MsgBox "Vous devez paramètrer une boite de dialogue !!", vbOKOnly + vbCritical, "Attention"
Me.Visible = True
Exit Sub
End If
End Sub
Private Sub mask()
If Check2.Value = 1 Then
Me.Visible = False
ElseIf Check1.Value = 2 Then
Me.Visible = True
End If
End Sub
Private Sub bep()
If Check1.Value = 1 Then
Beep
Beep
Beep
End If
End Sub

'textboxs de la frame1

Private Sub Text1_Click()
If Text1.Text = "Titre" Then
Text1.Text = ""
End If
End Sub
Private Sub Text1_gotfocus()
Call Text1_Click
End Sub
Private Sub Text2_Click()
If Text2.Text = "Ligne 1" Then
Text2.Text = ""
End If
End Sub
Private Sub Text2_gotfocus()
Call Text2_Click
End Sub
Private Sub Text3_Click()
If Text3.Text = "Ligne 2" Then
Text3.Text = ""
End If
End Sub
Private Sub Text3_gotfocus()
Call Text3_Click
End Sub
Private Sub Text4_Click()
If Text4.Text = "Ligne 3" Then
Text4.Text = ""
End If
End Sub
Private Sub Text4_gotfocus()
Call Text4_Click
End Sub
Private Sub Text5_Click()
If Text5.Text = "Ligne 4" Then
Text5.Text = ""
End If
End Sub
Private Sub Text5_gotfocus()
Call Text5_Click
End Sub
Private Sub Text6_Click()
If Text6.Text = "Ligne 5" Then
Text6.Text = ""
End If
End Sub
Private Sub Text6_gotfocus()
Call Text6_Click
End Sub
Private Sub Text1_LostFocus()
If Text1.Text = "" Then
Text1.Text = "Titre"
End If
End Sub
Private Sub Text2_LostFocus()
If Text2.Text = "" Then
Text2.Text = "Ligne 1"
End If
End Sub
Private Sub Text3_LostFocus()
If Text3.Text = "" Then
Text3.Text = "Ligne 2"
End If
End Sub
Private Sub Text4_LostFocus()
If Text4.Text = "" Then
Text4.Text = "Ligne 3"
End If
End Sub
Private Sub Text5_LostFocus()
If Text5.Text = "" Then
Text5.Text = "Ligne 4"
End If
End Sub
Private Sub Text6_LostFocus()
If Text6.Text = "" Then
Text6.Text = "Ligne 5"
End If
End Sub

'textboxs de la frame2 (non exploitée !)

Private Sub Text7_Click()
If Text7.Text = "Titre" Then
Text7.Text = ""
End If
End Sub
Private Sub Text7_gotfocus()
Call Text7_Click
End Sub
Private Sub Text8_Click()
If Text8.Text = "Ligne 1" Then
Text8.Text = ""
End If
End Sub
Private Sub Text8_gotfocus()
Call Text8_Click
End Sub
Private Sub Text9_Click()
If Text9.Text = "Ligne 2" Then
Text9.Text = ""
End If
End Sub
Private Sub Text9_gotfocus()
Call Text9_Click
End Sub
Private Sub Text10_Click()
If Text10.Text = "Ligne 3" Then
Text10.Text = ""
End If
End Sub
Private Sub Text10_gotfocus()
Call Text10_Click
End Sub
Private Sub Text11_Click()
If Text11.Text = "Ligne 4" Then
Text11.Text = ""
End If
End Sub
Private Sub Text11_gotfocus()
Call Text11_Click
End Sub
Private Sub Text12_Click()
If Text12.Text = "Ligne 5" Then
Text12.Text = ""
End If
End Sub
Private Sub Text12_gotfocus()
Call Text12_Click
End Sub
Private Sub Text7_LostFocus()
If Text7.Text = "" Then
Text7.Text = "Titre"
End If
End Sub
Private Sub Text8_LostFocus()
If Text8.Text = "" Then
Text8.Text = "Ligne 1"
End If
End Sub
Private Sub Text9_LostFocus()
If Text9.Text = "" Then
Text9.Text = "Ligne 2"
End If
End Sub
Private Sub Text10_LostFocus()
If Text10.Text = "" Then
Text10.Text = "Ligne 3"
End If
End Sub
Private Sub Text11_LostFocus()
If Text11.Text = "" Then
Text11.Text = "Ligne 4"
End If
End Sub
Private Sub Text12_LostFocus()
If Text12.Text = "" Then
Text12.Text = "Ligne 5"
End If
End Sub

Conclusion :


Bon si vous voulez pas le zip voici la liste des controles :
6 Textes boxs
4 images
2 bouton
2 frames
2 Checkboxs
2 groupes d'options (un de 4 et l'aute de 6)
et voila !
sinon tout est dans le zip !

Codes Sources

A voir également

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.