Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple text read

Status
Not open for further replies.

psybertek

Technical User
Mar 26, 2002
30
US
Hi all,
Back again. Ok, I have written a small routine to print checks, I am trying to get a label to change the check number based on data read from a text file.

So I want to open the text file read the number, assign the number to a label. Then I want to implement the number by one and over write the the text file with the new number.
so that when I open the file again it has the next checknumber in it.

I know this can't be very difficult, but I am having a hard time figuring out what the code is to read the text file into label14 thats the label I need to populate.

Psybertek
-----------------------------------
"Computer Junkies never die, they just upload."
 
This has been covered a few times, but to get you started:
Skeleton only, not full code!

ff = Freefile
Open myFileName For Input As ff
Do Until EOF(1)
Line Input ff, LineOfText
AllText = AllText & LineOfText & Wrap
Loop

Then use your text:

label14.text = myNumber

Then increment number
myNewNumber = myNumber + 1

Swap it:
AllText = Replace(AllText, myNumber, myNewNumber)

Then save the file again

For more detail, try Search on this site, looking for TEXTFILE, or VBHelp for 'open', 'replace' etc
Let me know if this helps
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
Thanx Johnwm,
after I posted this question, I came up with this solution.


Private Sub Form_Load()
checknumber = "E:\vb stuff\my projects\checknumber.txt"
Open checknumber For Input Access Read As #1
Input #1, chknum
Close #1
Text9.Text = chknum

Open checknumber For Output As #1
chknum = chknum + 1
Text9.Text = chknum
chknum = Text9.Text
Print #1, chknum
Close #1
End Sub


it does look kinda crude but it seems to be working. I will try your suggestion as well. thanx again, it really is nice to have a place to find help.


[alien] Psybertek [alien]
-------------------------------------------------
"Computer junkies never die, They just upload."

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top