tonywan
Messages postés34Date d'inscriptionmercredi 28 janvier 2004StatutMembreDernière intervention24 mars 2005
-
24 mars 2005 à 11:50
tonywan
Messages postés34Date d'inscriptionmercredi 28 janvier 2004StatutMembreDernière intervention24 mars 2005
-
24 mars 2005 à 14:45
Salut à tous,
je veux faire une boucle, je m'explique.
J'ai un txtdate, et je souhaite que si le txtdate.text n'est pas numéric
(If numeric = False Then
MsgBox ("Entrer une date correcte sous le format jjmmaaaa."))
alors un message âpparait, et j'aimerais alors revenir vers la saisi de la date quand je clique sur le bouton ok du msgbox.
sgrant
Messages postés89Date d'inscriptionmercredi 26 mai 2004StatutMembreDernière intervention13 mai 2005 24 mars 2005 à 14:27
Dans ce cas utilise exit sub, cad
If numeric = False Then
MsgBox ("Entrer une date correcte sous le format jjmmaaaa.")
textbox.setfocus()
'textbox etant le nom de l'objet contenant txtdate
exit sub 'interrompt l'execution de la procedure
end if
sgrant
Messages postés89Date d'inscriptionmercredi 26 mai 2004StatutMembreDernière intervention13 mai 2005 24 mars 2005 à 13:50
tu veux revenir sur le texbox contenant l'erreur si c le cas alors c plutot , c ca??
donc ce cas je pense que tu dois utiliser le code ci dessous:
If numeric = False Then
MsgBox ("Entrer une date correcte sous le format jjmmaaaa.")
textbox.setfocus()
'textbox etant le nom de l'objet contenant txtdate
end if
tonywan
Messages postés34Date d'inscriptionmercredi 28 janvier 2004StatutMembreDernière intervention24 mars 2005 24 mars 2005 à 14:26
Voilà mon programme :
Option Explicit
Dim compte(9999, 10 + 1) As String
Dim matricule(999, 4 + 1) As String
Dim ventil(9999) As String
Dim nb_quartz As Integer
Dim nb_compta As Integer
Dim nb_ventil As Integer
Dim tot_deb As Integer
Dim tot_cred As Integer
Private Sub cmdlanc_Click()
'****************************déclaration des variables********************
Dim i As Integer
Dim p As Integer
Dim ligne As String
Dim tout_quartz As String
Dim tout_compta As String
Dim raison As String
Dim num As String
Dim vbcrlf As String
Dim lig As String
Dim solde As String
Dim numeric As String
'txtdate.MousePointer = True
If txtdate.Text = "" Then
cmdlanc.Visible = False
Else
End If
c'est là que je veux que ça boucle. mon code juste en dessous ne me plait pas, car
comme tu vois le programme quitte quand ya une erreur de saisi, alors que je veux que ça revienne dans le txtdate SANS quitter le programme (fer une boucle en gros). Mais c'est là mon point faible...
numeric = IsNumeric(txtdate)
If numeric = False Then
MsgBox ("Entrer une date correcte sous le format jjmmaaaa.")
End
else
end if
'toutes les lignes sont stockées en mémoire
'**************************************************************************************************
Close #1
'****************************Ouverture du fichier COMPTA en lecture*****************************
Open (App.Path & "" & "Fichiers" & "" & "compta.txt") For Input As #1
nb_compta = 0 'initialisation du nombre de lignes
'1ere ligne stockée dans la variable "ligne"
tout_compta = ""
While Not EOF(1)
Line Input #1, ligne
tout_compta = tout_compta & ligne & vbcrlf
If id = "C" Then
tot_cred = tot_cred + ecart
Else
tot_deb = tot_deb + ecart
End If
Else
i_scan = i_scan + 1
End If
Wend
End If
txtdeb.Text = tot_deb
txtcred.Text = tot_cred
'Kill "ventil.txt"
Dim fichier As String
fichier = InputBox("Entrer un nom du fichier de l'enregistrement de cette ventilation : ")
Open (App.Path & "" & "Fichiers" & "" & "" & fichier & ".txt") For Output As #3
For j = 1 To nb_ventil
Print #3, ventil(j)
Next j
MsgBox ("Votre fichier " & fichier & ".txt a été enregistré avec succès dans le répertoire FICHIERS")
Close #3
Dim reponse As Variant
reponse = MsgBox("Voulez-vous quitter le programme ?", vbYesNo)
If reponse = vbNo Then
Else
End
End
End If
End Sub
Function pourcent(mat As String, r As String, n As String) As Long
Dim i As Integer
Dim flag As Boolean
i = 0
flag = False
While i < nb_quartz And flag = False
If matricule(i, 1) mat And matricule(i, 2) r And matricule(i, 3) = n Then
flag = True
Else
i = i + 1
End If
Wend
If flag = True Then
pourcent = matricule(i, 4) / 100
Else
pourcent = 1
End If
End Function
Private Sub Form_Load()
If txtdate.Text <> "" Then
cmdlanc.Visible = False
End If