Gruppe
Extern
Problem
Wie kann ich die Rechnungsnummer aus einer Textdatei abrufen und diese dort automatisch hochzählen lassen, so daß mir beim nächsten Aufruf die nächsthöhere Nummer zur Verfügung steht?
StandardModule: basMain
Sub InvoiceIni()
Dim sFile As String, sNo As String
Dim iNo As Integer, iFile As Integer
iFile = FreeFile
sFile = Application.Path & "\Invoice.ini"
If Dir(sFile) <> "Invoice.ini" Then
iNo = 1
Open sFile For Output As iFile
Print #iFile, iNo
Close
Else
Open sFile For Input As iFile
Do Until EOF(iFile)
Input #1, sNo
Loop
Close
iNo = CInt(sNo) + 1
Open sFile For Output As iFile
Print #iFile, iNo
Close
End If
Range("A1").Value = iNo
End Sub
Sub ResetNo()
Dim sFile As String
sFile = Application.Path & "\Invoice.ini"
If Dir(sFile) <> "" Then Kill sFile
Range("A1").Value = 0
End Sub