0

At the moment I am currently working on a program (for school) that saves and reads CD album information from a file (pre-made).

The information that can be saved (and read) is the album title, the artist, the recording group, the genre, the date purchased (in the DD/MM/YYYY format) and the price. The issue, however, is that whenever the user browses through the different files, the date purchased is not read correctly, and instead only displays the DD.

I've figured out that Visual Basic only reads the date correctly when the date (in the datafile) is in quoatation marks (""). So, my questions are: how can I save the data to the file in quoatation marks or how can I get Visual Basic to read the date from the file correctly?

I don't have my code on me right now, but I'll go by memory. (By the way, a horizontal scroll bar is used by the user to select which set of data they want to view).

Private Sub hsbRecord_Change()

Open "<filename>" For Input As #1
While tempCount <> hsbRecord.Value
tempCount = tempCount + 1
Input #1, tempCD
Input #1, tempArtist
Input #1, tempGroup
Input #1, tempGenre
Input #1, tempPurchase
Input #1, tempPrice
Wend
Close #1

txtTitle.Text = tempCD
txtArtist.Text = tempArtist
txtRecording.Text = tempGroup
txtType.Text = tempGenre
txtPurchase.Text = tempPurchase
txtPrice.Text = tempPrice

End Sub
Private Sub cmdSave_Click()

Open "<file name>" For Append As #1
Print #1, txtTitle.Text
Print #1, txtArtist.Text
Print #1, txtRecording.Text
Print #1, txtType.Text
Print #1, txtPurchase.Text
Print #1, txtPrice.Text
Close #1

End Sub
2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Rakyu
0

Use the Line Input function instead of the input function. Line Input will read the entire line.


Good Luck

0

Use the Line Input function instead of the input function. Line Input will read the entire line.


Good Luck

Thanks! That was the solution I needed.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.