Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.
Sub Test MsgBox(oGet_Invoice_Number) End Sub Function oGet_Invoice_Number() As Long Try Dim oLastInvoiceNumber As Long Dim oInvoiceNumber As Long If System.IO.Directory.Exists("c:\Program Files\KISS_Accounting") = False Then System.IO.Directory.CreateDirectory("c:\Program Files\KISS_Accounting") End If Dim FILE_NAME As String = "c:\Program Files\KISS_Accounting\Invoice_Number.txt" 'So first see if text file is there - if not write the initial file with 1 as number If System.IO.File.Exists(FILE_NAME) = False Then Dim oWriter As New System.IO.StreamWriter(FILE_NAME) oWriter.Write("1") oWriter.Close() oGet_Invoice_Number = 1 Exit Function Else Dim oReader As New System.IO.StreamReader(FILE_NAME) Dim oReadLine As String = oReader.Read() oLastInvoiceNumber = CLng(oReadLine) oReader.Close() oInvoiceNumber = oLastInvoiceNumber + 1 Dim oWriter As New System.IO.StreamWriter(FILE_NAME) oWriter.Write(CStr(oInvoiceNumber)) oWriter.Close() oGet_Invoice_Number = oInvoiceNumber End If Catch ex As Exception MsgBox(ex.Message) End Try
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.