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

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


Good Luck

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.