Hi again, I am pretty sure this didn't post twice. Anyway, I have this program which I am supposed to make which requires me to write to a txt file then read it. Now I looked through the msg boards and found lots of things about this, however, nothing which is what i need exactly, or it was there and I just didn't understand it.
I have 4 textboxes. One is name, Second is Artist, Third is Price and forth is path.
I can get them all to work except the price which always shows up as 0 in the textbox.
My real problem is with reading it. When i click my retrieve button it is supposed to hide the first form and open a second one which is exactly alike except for no path textbox or save. I need the information which is printed into the textbox to go into the corresponding textboxes in the 2nd form. In the first form I have a save button which writes to the file, it can save multiple times and what I need as well is when it is saved multiple times I can click retrieve for the next form then on that form click another button called retrieve next which would give me the info on the 2nd line and put it in the corresponding textboxes.
My code for the write is below, I don't have any for retrieve yet except just hiding and showing the forms. I tried a few ways from reading the msg board but none would work how I need them.
Anyhelp would be great
Thanks
Code:
Private Sub cmdSave_Click()
Dim strTitle As String
Dim strArtist As String
Dim curPrice As Currency
strTitle = txtTitle.Text
strArtist = txtArtist.Text
curPrice = Val(curPrice)
Dim ff&
ff = FreeFile
Open "h:\test.txt" For Append As #ff
Write #ff, strTitle, strArtist, curPrice
Close #ff
txtTitle = ""
txtArtist = ""
txtPrice = ""
End Sub
Private Sub cmdSave_Click()
Dim strTitle As String
Dim strArtist As String
Dim curPrice As Currency
strTitle = txtTitle.Text
strArtist = txtArtist.Text
curPrice = Val(curPrice)
Dim ff&
ff = FreeFile
Open "h:\test.txt" For Append As #ff
*Write #ff, strTitle, strArtist, curPrice
Print #ff, strTitle, strArtist, curPrice
Close #ff
txtTitle = ""
txtArtist = ""
txtPrice = ""
End Sub
tried that, it didn't work though, it just took away the quotations
and commas in the text lines and put a big space between the artist text and price.
since you're saving it to a text file, I would just change the currency to a string. What I mean is declare it as a string. You can change it to currency if you need to in the program by having a second variable.
VB Code:
'Declarations
dim curPrice as currency
Sub Whatever
dim sCur as string
''''''.......................
get #1, sCur
close #1
' I'm not sure if this is right since I don't ever work with
Remember its just the basics, u will need some code to check
for things like:
File empty, File dosn't exist etc.
And ull need to fiddle with the Currency.
Good Luck
Last edited by Bruce Fox; Apr 17th, 2002 at 01:25 AM.