- Function IsValid() As Boolean
- Dim Ctl As Control
- For Each Ctl In Controls
- If TypeOf Ctl Is TextBox Then
- Select Case Ctl.Tag
- Case "r" 'Le champs est requis
- If Len(Trim(Ctl.Text)) = 0 Then
- MsgBox Ctl.DataField & " : La donnée est requise !", vbExclamation
- Ctl.SetFocus
- SendKeys "^{HOME}+^{END}", True
- Exit Function
- End If
- Case "n" 'Champs requis numérique
- If Not IsNumeric(Ctl.Text) Then
- MsgBox Ctl.DataField & " : La donnée doit être numérique !", vbExclamation
- Ctl.SetFocus
- SendKeys "^{HOME}+^{END}", True
- Exit Function
- End If
- Case "+" 'Champs requis positif
- If Not (IsNumeric(Ctl.Text) And Val(Ctl.Text) > 0) Then
- MsgBox Ctl.DataField & " : La donnée doit être numérique positive !", vbExclamation
- Ctl.SetFocus
- SendKeys "^{HOME}+^{END}", True
- Exit Function
- End If
- Case "-" 'Champs requis négatif
- If Not (IsNumeric(Ctl.Text) And Val(Ctl.Text) < 0) Then
- MsgBox Ctl.DataField & " : La donnée doit être numérique négative !", vbExclamation
- Ctl.SetFocus
- SendKeys "^{HOME}+^{END}", True
- Exit Function
- End If
- End Select
- End If
- Next
- IsValid = True
- End Function
-
Function IsValid() As Boolean
Dim Ctl As Control
For Each Ctl In Controls
If TypeOf Ctl Is TextBox Then
Select Case Ctl.Tag
Case "r" 'Le champs est requis
If Len(Trim(Ctl.Text)) = 0 Then
MsgBox Ctl.DataField & " : La donnée est requise !", vbExclamation
Ctl.SetFocus
SendKeys "^{HOME}+^{END}", True
Exit Function
End If
Case "n" 'Champs requis numérique
If Not IsNumeric(Ctl.Text) Then
MsgBox Ctl.DataField & " : La donnée doit être numérique !", vbExclamation
Ctl.SetFocus
SendKeys "^{HOME}+^{END}", True
Exit Function
End If
Case "+" 'Champs requis positif
If Not (IsNumeric(Ctl.Text) And Val(Ctl.Text) > 0) Then
MsgBox Ctl.DataField & " : La donnée doit être numérique positive !", vbExclamation
Ctl.SetFocus
SendKeys "^{HOME}+^{END}", True
Exit Function
End If
Case "-" 'Champs requis négatif
If Not (IsNumeric(Ctl.Text) And Val(Ctl.Text) < 0) Then
MsgBox Ctl.DataField & " : La donnée doit être numérique négative !", vbExclamation
Ctl.SetFocus
SendKeys "^{HOME}+^{END}", True
Exit Function
End If
End Select
End If
Next
IsValid = True
End Function