|
-
Feb 5th, 2006, 11:12 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Picking value from Text File and App.Path
Hi,
I want my application to store the last Ticket No in a text file and when it starts again, it should pick the last number and increment it by 1 to start again.
I am not following how to pick the value written in text file, though I attempted as below:
Code:
Public Function LoadPNoFromFile()
Dim fs As IO.FileStream = New IO.FileStream("C:\KTR\KTR\ePermit2\Data\pno.txt", IO.FileMode.OpenOrCreate, IO.FileAccess.ReadWrite)
Dim br As IO.BinaryReader = New IO.BinaryReader(fs)
Dim bw As IO.BinaryWriter = New IO.BinaryWriter(fs)
Dim GetNum(1000) As Byte
Dim myVal As Long
Try
myVal = br.ReadByte
MsgBox(myVal)
fs.Close()
Catch ex As Exception
End Try
End Function
Secondly, how to use App.Path (of VB6) here in the code in the line where the path of the Text File is given.
Last edited by rpk_20061975; Feb 5th, 2006 at 11:40 AM.
-
Feb 5th, 2006, 11:30 AM
#2
Re: Picking value from Text File and App.Path
First question - You should check out using streamreader instead of filestream and binaryreader if it's a text file.
VB Code:
Dim sr As New IO.StreamReader("Mytextfile")
Dim Ticketno as String
While Not (sr.Peek() = -1)
Ticketno = Sr.ReadLine()
End While
SR.Close()
'This will leave you with ticketno containing the last line of the text file.
'Then to write back the next one.
Dim sw As New IO.StreamWriter("MyTextFile", True) 'append is true
Sw.WriteLine(TheNextTicketNumber)
sw.Close()
And for question two:
Application.StartupPath
Bill
-
Feb 5th, 2006, 11:39 AM
#3
Thread Starter
Addicted Member
Re: Picking value from Text File and App.Path
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|