FredBel
Messages postés11Date d'inscriptionvendredi 31 octobre 2003StatutMembreDernière intervention21 avril 2009
-
2 avril 2009 à 10:36
FredBel
Messages postés11Date d'inscriptionvendredi 31 octobre 2003StatutMembreDernière intervention21 avril 2009
-
21 avril 2009 à 11:58
Bonjour à tous,
Un petit problème.
J'ai réalisé un petit logiciel en VB avec gestion de base de données Access.
Lorsque, dans un des champs (numérique) du formulaire, un de mes collègues introduit, sur son pc, un montant supérieur à 1000, le programme se plante en indiquant "Erreur d'exécution 3421: erreur de conversion de type de données".
Lorsque je fais la même chose sur mon pc ou sur celui d'un autre collègue, tout se passe sans problème.
Quelqu'un peut-il m'aider à résoudre ce bin's ?
FredBel
Messages postés11Date d'inscriptionvendredi 31 octobre 2003StatutMembreDernière intervention21 avril 2009 2 avril 2009 à 11:23
Ben non, justement pas.
C'est la première chose que j'ai vérifiée.
Mon collègue et moi, on a exactement les mêmes paramètres régionaux.
Le pire de tout, c'est que sur l'autre pc sur lequel ça marche, les paramètres régionaux sont différents.
Comprenne qui pourra. !!
Mais, autant vous dire que j'espère une réponse.... mdrrrr.
FredBel
Messages postés11Date d'inscriptionvendredi 31 octobre 2003StatutMembreDernière intervention21 avril 2009 2 avril 2009 à 11:59
Oups, désolé pour la touche "Réponse acceptée"
Voici une partie du code, certainement bourrés d'erreurs puisque j'ai appris le VB par moi-même, au boulot, et on m'a demandé de réaliser un programme en un minimum de temps.
Apparemment, c'est soit dans le champ du PrixUnitaire ou du PrixTotal que ça bugue, mais pourquoi, j'en sais rien.
Private Sub txtPrixUnitaire01DemandeBon_GotFocus()
'Calculer le nombre de caractère contenus dans la zone de texte
intLongueurChaine = Len(txtPrixUnitaire01DemandeBon.Text)
'Mettre le texte de la zone de texte en surbrillance
txtPrixUnitaire01DemandeBon.SelStart = 0
txtPrixUnitaire01DemandeBon.SelLength = intLongueurChaine
End Sub
Private Sub txtPrixUnitaire01DemandeBon_KeyPress(KeyAscii As Integer)
If KeyAscii = 46 Then
KeyAscii = 44
End If If KeyAscii 13 Or KeyAscii 9 Then
strChaineIntroduite = txtPrixUnitaire01DemandeBon.Text
ContrôleValiditéPrixUnitaire
If blnContrôleValiditéPrixUnitaire Then
'Mettre le champ du prix total à jour
txtPrixTotal01DemandeBon.Text = CDec(txtQuantité01DemandeBon.Text) * CDec(txtPrixUnitaire01DemandeBon.Text)
'Placer le focus sur la quantité
txtQuantité02DemandeBon.SetFocus
Else
gbStrMessage = MsgBox("Veuillez introduire une prix correct !!", vbOKOnly + vbExclamation + vbApplicationModal, gbTitreBoiteDeDialogue)
txtPrixUnitaire01DemandeBon.Text = ""
txtPrixUnitaire01DemandeBon.SetFocus
Exit Sub
End If
End If
End Sub
Private Sub txtPrixUnitaire01DemandeBon_LostFocus()
If gbBlnModifier Then
If txtPrixUnitaire01DemandeBon.Text = "" Then
txtPrixTotal01DemandeBon.Text = ""
End If
End If
End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Renfield
Messages postés17287Date d'inscriptionmercredi 2 janvier 2002StatutModérateurDernière intervention27 septembre 202174 2 avril 2009 à 12:37
testes ce code :
Private Const LOCALE_SDECIMAL As Long = &HE
Private Declare Function GetLocaleInfo Lib "kernel32.dll" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long
Private Sub txtPrixUnitaire01DemandeBon_GotFocus()
With txtPrixUnitaire01DemandeBon
.SelStart = 0
.SelLength = Len(.Text)
End With
End Sub
Private Function GetDecimalSeparator() As String
Dim nLength As Long
Dim sbuffer As String * 25
nLength = GetLocaleInfo(0, LOCALE_SDECIMAL, sbuffer, 25)
If nLength Then
GetDecimalSeparator = Left$(sbuffer, nLength)
End If
End Function
Private Sub txtPrixUnitaire01DemandeBon_KeyPress(KeyAscii As Integer)
If KeyAscii = 46 Then
KeyAscii = AscW(GetDecimalSeparator)
ElseIf KeyAscii 13 Or KeyAscii 9 Then
Me.ValidateControls
txtQuantité02DemandeBon.SetFocus
End If
End Sub
Private Sub txtPrixUnitaire01DemandeBon_Validate(Cancel As Boolean)
Dim nPrice As Double
If IsNumeric(txtPrixUnitaire01DemandeBon.Text) Then
nPrice = CDbl(txtPrixUnitaire01DemandeBon.Text)
Else
nPrice = Val(txtPrixUnitaire01DemandeBon.Text)
End If
If nPrice Then
txtPrixTotal01DemandeBon.Text = FormatNumber(Val(txtQuantité01DemandeBon.Text) * nPrice)
txtPrixUnitaire01DemandeBon.Text = FormatNumber(nPrice)
Else
MsgBox "Veuillez introduire une prix correct !!", vbExclamation Or vbApplicationModal
Cancel = True
End If
End Sub
FredBel
Messages postés11Date d'inscriptionvendredi 31 octobre 2003StatutMembreDernière intervention21 avril 2009 8 avril 2009 à 14:17
Merci pour la réponse, mais j'aurai encore quelques questions de novice.
Que font ces commandes ?
Private Const LOCALE_SDECIMAL As Long = &HE
Private Declare Function GetLocaleInfo Lib "kernel32.dll" Alias "GetLocaleInfoA" (ByVal Locale As Long, ByVal LCType As Long, ByVal lpLCData As String, ByVal cchData As Long) As Long
Private Function GetDecimalSeparator() As String
Dim nLength As Long
Dim sbuffer As String * 25
nLength = GetLocaleInfo(0, LOCALE_SDECIMAL, sbuffer, 25)
If nLength Then
GetDecimalSeparator = Left$(sbuffer, nLength)
End If
End Function
Que fait la commande AscW ?
Private Sub txtPrixUnitaire01DemandeBon_KeyPress(KeyAscii As Integer)
If KeyAscii = 46 Then
KeyAscii = AscW(GetDecimalSeparator) ElseIf KeyAscii 13 Or KeyAscii 9 Then
Me.ValidateControls
txtQuantité02DemandeBon.SetFocus
End If
End Sub
Je n'ai pas trop bien compris l'utilisation de nPrice, surtout dans le test "If nPrice"
Private Sub txtPrixUnitaire01DemandeBon_Validate(Cancel As Boolean)
Dim nPrice As Double
If IsNumeric(txtPrixUnitaire01DemandeBon.Text) Then
nPrice = CDbl(txtPrixUnitaire01DemandeBon.Text)
Else
nPrice = Val(txtPrixUnitaire01DemandeBon.Text)
End If
If nPrice Then
txtPrixTotal01DemandeBon.Text = FormatNumber(Val(txtQuantité01DemandeBon.Text) * nPrice)
txtPrixUnitaire01DemandeBon.Text = FormatNumber(nPrice)
Else
MsgBox "Veuillez introduire une prix correct !!", vbExclamation Or vbApplicationModal
Cancel = True
End If
End Sub
FredBel
Messages postés11Date d'inscriptionvendredi 31 octobre 2003StatutMembreDernière intervention21 avril 2009 21 avril 2009 à 11:58
Après codage, toujours pareil sur le même pc.
Dernière solution: j'ai copié toutes mes polices de caractères sur le pc de mon collègue et, bingo, ça fonctionne !!!
Comprenne qui pourra.
Celui qui me donnera l'explication aura droit à ma reconnaissance éternelle !