Voila , jai une fonction qui serait supposé écrire dans un fichier , mais
j'ai droit a un "Bad File Mode (erreur 54)". Comme je suis débutant ,
j'aimerais bien me faire expliqué où est mon erreur . Merci d'avance :)
Public Sub EcrireBalanceComptes()
Dim strNumeroCompte As String
Dim sngBalanceCompteCheque As Single
Dim sngBalanceCompteEpargne As Single
Dim Temp As Single
Dim MontantFacture As Single
Open App.Path & "\Comptes.dat" For Input As #1
Do While Not EOF(1)
Input #1, strNumeroCompte, sngBalanceCompteCheque,
sngBalanceCompteEpargne
If strNumeroCompte = gstrUtilisateurNumeroCompte Then
gsngUtilisateurBalanceCompteCheque = sngBalanceCompteCheque
gsngUtilisateurBalanceCompteEpargne = sngBalanceCompteEpargne
Select Case gstrTypeTransaction
'Cas d'un dépot
Case "D"
If gstrTypeCompte = "C" Then
Write #1, strNumeroCompte; (sngBalanceCompteCheque +
gsngMontantTransaction); sngBalanceCompteEpargne
Else
Write #1, strNumeroCompte; sngBalanceCompteCheque;
(sngBalanceCompteEpargne + gsngMontantTransaction)
End If
'Cas de retrait
Case "R"
If gstrTypeCompte = "C" Then
If (sngBalanceCompteCheque - gsngMontantTransaction) < 0
Then
MsgBox ("Vous n'avez pas assez d'argent pour
effectuer ce retrait")
Exit Sub
End If
Write #1, strNumeroCompte, (sngBalanceCompteCheque -
gsngMontantTransaction), sngBalanceCompteEpargne
Else
If (sngBalanceCompteEpargne - gsngMontantTransaction) <
0 Then
MsgBox ("Vous n'avez pas assez d'argent pour
effectuer ce retrait")
Exit Sub
End If
Write #1, strNumeroCompte; sngBalanceCompteCheque;
(sngBalanceCompteEpargne - gsngMontantTransaction)
End If
'Cas d'un transfert
Case "T"
If frmTransactionTransfert.Option1 = True Then
Temp = sngBalanceCompteCheque - gsngMontantTransaction
Write #1, strNumeroCompte; sngBalanceCompteCheque;
(sngBalanceCompteEpargne + Temp)
End If
If frmTransactionTransfert.Option2 = True Then
Temp = sngBalanceCompteEpargne - gsngMontantTransaction
Write #1, strNumeroCompte; (sngBalanceCompteCheque +
Temp); sngBalanceCompteEpargne
End If
'Cas d'un paiment de facture
Case "P"
MontantFacture = gsngMontantTransaction +
FRAIS_PAIEMENT_FACTURE
If MontantFacture >= 10000 Then
MsgBox ("Vous ne pouvez pas règler une facture de plus
de 10 000$")
Exit Sub
End If
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Christian Hugoud
En première lecture, tu ouvres le fichier for Input. Tu ne peux pas écrire dedans dans ce cas.
Christian
"VBDébutant" <VBDé a écrit dans le message de news:
Voila , jai une fonction qui serait supposé écrire dans un fichier , mais j'ai droit a un "Bad File Mode (erreur 54)". Comme je suis débutant , j'aimerais bien me faire expliqué où est mon erreur . Merci d'avance :)
Public Sub EcrireBalanceComptes() Dim strNumeroCompte As String Dim sngBalanceCompteCheque As Single Dim sngBalanceCompteEpargne As Single Dim Temp As Single Dim MontantFacture As Single Open App.Path & "Comptes.dat" For Input As #1
Do While Not EOF(1) Input #1, strNumeroCompte, sngBalanceCompteCheque, sngBalanceCompteEpargne If strNumeroCompte = gstrUtilisateurNumeroCompte Then gsngUtilisateurBalanceCompteCheque = sngBalanceCompteCheque gsngUtilisateurBalanceCompteEpargne = sngBalanceCompteEpargne Select Case gstrTypeTransaction 'Cas d'un dépot Case "D" If gstrTypeCompte = "C" Then Write #1, strNumeroCompte; (sngBalanceCompteCheque + gsngMontantTransaction); sngBalanceCompteEpargne Else Write #1, strNumeroCompte; sngBalanceCompteCheque; (sngBalanceCompteEpargne + gsngMontantTransaction) End If 'Cas de retrait Case "R" If gstrTypeCompte = "C" Then If (sngBalanceCompteCheque - gsngMontantTransaction) < 0 Then MsgBox ("Vous n'avez pas assez d'argent pour effectuer ce retrait") Exit Sub End If Write #1, strNumeroCompte, (sngBalanceCompteCheque - gsngMontantTransaction), sngBalanceCompteEpargne Else If (sngBalanceCompteEpargne - gsngMontantTransaction) < 0 Then MsgBox ("Vous n'avez pas assez d'argent pour effectuer ce retrait") Exit Sub End If Write #1, strNumeroCompte; sngBalanceCompteCheque; (sngBalanceCompteEpargne - gsngMontantTransaction) End If 'Cas d'un transfert Case "T" If frmTransactionTransfert.Option1 = True Then Temp = sngBalanceCompteCheque - gsngMontantTransaction Write #1, strNumeroCompte; sngBalanceCompteCheque; (sngBalanceCompteEpargne + Temp) End If If frmTransactionTransfert.Option2 = True Then Temp = sngBalanceCompteEpargne - gsngMontantTransaction Write #1, strNumeroCompte; (sngBalanceCompteCheque + Temp); sngBalanceCompteEpargne End If 'Cas d'un paiment de facture Case "P" MontantFacture = gsngMontantTransaction + FRAIS_PAIEMENT_FACTURE If MontantFacture >= 10000 Then MsgBox ("Vous ne pouvez pas règler une facture de plus de 10 000$") Exit Sub End If
End Select End If Loop Close #1 End Sub
En première lecture, tu ouvres le fichier for Input. Tu ne peux pas écrire
dedans dans ce cas.
Christian
"VBDébutant" <VBDébutant@discussions.microsoft.com> a écrit dans le message
de news: 46AB43DA-7EFE-4E25-ADAE-57572932B95A@microsoft.com...
Voila , jai une fonction qui serait supposé écrire dans un fichier , mais
j'ai droit a un "Bad File Mode (erreur 54)". Comme je suis débutant ,
j'aimerais bien me faire expliqué où est mon erreur . Merci d'avance :)
Public Sub EcrireBalanceComptes()
Dim strNumeroCompte As String
Dim sngBalanceCompteCheque As Single
Dim sngBalanceCompteEpargne As Single
Dim Temp As Single
Dim MontantFacture As Single
Open App.Path & "Comptes.dat" For Input As #1
Do While Not EOF(1)
Input #1, strNumeroCompte, sngBalanceCompteCheque,
sngBalanceCompteEpargne
If strNumeroCompte = gstrUtilisateurNumeroCompte Then
gsngUtilisateurBalanceCompteCheque = sngBalanceCompteCheque
gsngUtilisateurBalanceCompteEpargne = sngBalanceCompteEpargne
Select Case gstrTypeTransaction
'Cas d'un dépot
Case "D"
If gstrTypeCompte = "C" Then
Write #1, strNumeroCompte; (sngBalanceCompteCheque +
gsngMontantTransaction); sngBalanceCompteEpargne
Else
Write #1, strNumeroCompte; sngBalanceCompteCheque;
(sngBalanceCompteEpargne + gsngMontantTransaction)
End If
'Cas de retrait
Case "R"
If gstrTypeCompte = "C" Then
If (sngBalanceCompteCheque - gsngMontantTransaction) <
0
Then
MsgBox ("Vous n'avez pas assez d'argent pour
effectuer ce retrait")
Exit Sub
End If
Write #1, strNumeroCompte, (sngBalanceCompteCheque -
gsngMontantTransaction), sngBalanceCompteEpargne
Else
If (sngBalanceCompteEpargne - gsngMontantTransaction) <
0 Then
MsgBox ("Vous n'avez pas assez d'argent pour
effectuer ce retrait")
Exit Sub
End If
Write #1, strNumeroCompte; sngBalanceCompteCheque;
(sngBalanceCompteEpargne - gsngMontantTransaction)
End If
'Cas d'un transfert
Case "T"
If frmTransactionTransfert.Option1 = True Then
Temp = sngBalanceCompteCheque - gsngMontantTransaction
Write #1, strNumeroCompte; sngBalanceCompteCheque;
(sngBalanceCompteEpargne + Temp)
End If
If frmTransactionTransfert.Option2 = True Then
Temp = sngBalanceCompteEpargne - gsngMontantTransaction
Write #1, strNumeroCompte; (sngBalanceCompteCheque +
Temp); sngBalanceCompteEpargne
End If
'Cas d'un paiment de facture
Case "P"
MontantFacture = gsngMontantTransaction +
FRAIS_PAIEMENT_FACTURE
If MontantFacture >= 10000 Then
MsgBox ("Vous ne pouvez pas règler une facture de plus
de 10 000$")
Exit Sub
End If
En première lecture, tu ouvres le fichier for Input. Tu ne peux pas écrire dedans dans ce cas.
Christian
"VBDébutant" <VBDé a écrit dans le message de news:
Voila , jai une fonction qui serait supposé écrire dans un fichier , mais j'ai droit a un "Bad File Mode (erreur 54)". Comme je suis débutant , j'aimerais bien me faire expliqué où est mon erreur . Merci d'avance :)
Public Sub EcrireBalanceComptes() Dim strNumeroCompte As String Dim sngBalanceCompteCheque As Single Dim sngBalanceCompteEpargne As Single Dim Temp As Single Dim MontantFacture As Single Open App.Path & "Comptes.dat" For Input As #1
Do While Not EOF(1) Input #1, strNumeroCompte, sngBalanceCompteCheque, sngBalanceCompteEpargne If strNumeroCompte = gstrUtilisateurNumeroCompte Then gsngUtilisateurBalanceCompteCheque = sngBalanceCompteCheque gsngUtilisateurBalanceCompteEpargne = sngBalanceCompteEpargne Select Case gstrTypeTransaction 'Cas d'un dépot Case "D" If gstrTypeCompte = "C" Then Write #1, strNumeroCompte; (sngBalanceCompteCheque + gsngMontantTransaction); sngBalanceCompteEpargne Else Write #1, strNumeroCompte; sngBalanceCompteCheque; (sngBalanceCompteEpargne + gsngMontantTransaction) End If 'Cas de retrait Case "R" If gstrTypeCompte = "C" Then If (sngBalanceCompteCheque - gsngMontantTransaction) < 0 Then MsgBox ("Vous n'avez pas assez d'argent pour effectuer ce retrait") Exit Sub End If Write #1, strNumeroCompte, (sngBalanceCompteCheque - gsngMontantTransaction), sngBalanceCompteEpargne Else If (sngBalanceCompteEpargne - gsngMontantTransaction) < 0 Then MsgBox ("Vous n'avez pas assez d'argent pour effectuer ce retrait") Exit Sub End If Write #1, strNumeroCompte; sngBalanceCompteCheque; (sngBalanceCompteEpargne - gsngMontantTransaction) End If 'Cas d'un transfert Case "T" If frmTransactionTransfert.Option1 = True Then Temp = sngBalanceCompteCheque - gsngMontantTransaction Write #1, strNumeroCompte; sngBalanceCompteCheque; (sngBalanceCompteEpargne + Temp) End If If frmTransactionTransfert.Option2 = True Then Temp = sngBalanceCompteEpargne - gsngMontantTransaction Write #1, strNumeroCompte; (sngBalanceCompteCheque + Temp); sngBalanceCompteEpargne End If 'Cas d'un paiment de facture Case "P" MontantFacture = gsngMontantTransaction + FRAIS_PAIEMENT_FACTURE If MontantFacture >= 10000 Then MsgBox ("Vous ne pouvez pas règler une facture de plus de 10 000$") Exit Sub End If