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
| Private Sub CmdCalcul_Click()
If VerifChampsMini = True Then
'lancer le calcul
Else
'un MsgBox a renseigné le minimum des entrées utiles pour le calcul
'donc ne lance pas le calcul
End If
End Sub
Public Function VerifChampsMini() As Boolean
VerifChampsMini = True
Dim LeControl As Control
Dim ProblemTxt As Boolean, ProblemOpt As Boolean
ProblemTxt = False
For Each LeControl In Controls
If VarType(LeControl) = 8 Then 'TextBox
If Trim(LeControl.Text) = "" Then
VerifChampsMini = False: ProblemTxt = True: Exit For
End If
End If
Next
ProblemOpt = False
For Each LeControl In Controls
If VarType(LeControl) = 11 Then 'OptionButton
If Trim(LeControl.Value) = True Then
VerifChampsMini = False: ProblemOpt = True: Exit For
End If
End If
Next
Dim Msg$
If ProblemTxt = True Then Msg$ = "Tous les textbox doivent être renseignés" & vbCrLf
If ProblemOpt = True Then Msg$ = Msg$ & "Vous devez choisir une option"
If Msg$ <> "" Then MsgBox Msg$, vbInformation, "manque d'informations"
End Function |
Partager