|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
.dat retrieval and displaySending to the file is fine, but the retrieval won't. Code is: Private Sub cmdDisplayFile_Click() Dim index As Integer Dim DataToDisplay As String Dim Quantity As String * 4 Dim Price As String * 6 Dim reOrderLevel As String * 3 Dim product As OneProduct filename = txtFileName.Text lstDisplayFile.Clear Open filename For Random As #1 Len = Len(product) For index = 1 To NumberofRecords 'Numberofrecords declared in general section and passed: 'NumberofRecords = LOF(1) / Len(product) Dim index As Integer Dim DataToDisplay As String Dim Quantity As String * 4 Dim Price As String * 6 Dim reOrderLevel As String * 3 Dim product As OneProduct filename = txtFileName.Text lstDisplayFile.Clear Open filename For Random As #1 Len = Len(product) For index = 1 To NumberofRecords Get #1, , product Quantity = product.QuantityinStock Price = Format(product.Price, "currency") reOrderLevel = product.reOrderLevel DataToDisplay = product.productID & " " & product.Description _ & " " & Quantity & " " & Price & " " & reOrderLevel Next index Close #1 Get #1, , product Quantity = product.QuantityinStock Price = Format(product.Price, "currency") reOrderLevel = product.reOrderLevel DataToDisplay = product.productID & " " & product.Description _ & " " & Quantity & " " & Price & " " & reOrderLevel Next index Close #1 End Sub No error is thrown just no return to the listbox (hace checked props, is set to visible and enabled) Any help greatly appreciated Mick Is this your cut 'n' pasted code? For instance, I see these two lines
> Close #1 which would surely raise an error. Further, I see no reference to thefollowed by > Get #1, , product listbox other than > lstDisplayFile.Clear, i. e. there is no lstDisplayFile.AddItem Paste your code into your post. Also show the definition for OneProduct Show quoteHide quote "Mick Whyte" <mick.wh***@gmail.com> wrote in message news:1138729940.594338.73410@o13g2000cwo.googlegroups.com... > Hi am working on an app that uses .dat file to store and retrieve. > Sending to the file is fine, but the retrieval won't. Code is: > > Private Sub cmdDisplayFile_Click() > Dim index As Integer > Dim DataToDisplay As String > Dim Quantity As String * 4 > Dim Price As String * 6 > Dim reOrderLevel As String * 3 > Dim product As OneProduct > filename = txtFileName.Text > lstDisplayFile.Clear > Open filename For Random As #1 Len = Len(product) > > > > For index = 1 To NumberofRecords > 'Numberofrecords declared in general section and passed: > 'NumberofRecords = LOF(1) / Len(product) > Dim index As Integer > Dim DataToDisplay As String > Dim Quantity As String * 4 > Dim Price As String * 6 > Dim reOrderLevel As String * 3 > Dim product As OneProduct > filename = txtFileName.Text > lstDisplayFile.Clear > Open filename For Random As #1 Len = Len(product) > > > > For index = 1 To NumberofRecords > > Get #1, , product > Quantity = product.QuantityinStock > Price = Format(product.Price, "currency") > reOrderLevel = product.reOrderLevel > > DataToDisplay = product.productID & " " & product.Description _ > & " " & Quantity & " " & Price & " " & reOrderLevel > > > Next index > > > Close #1 > > Get #1, , product > Quantity = product.QuantityinStock > Price = Format(product.Price, "currency") > reOrderLevel = product.reOrderLevel > > DataToDisplay = product.productID & " " & product.Description _ > & " " & Quantity & " " & Price & " " & reOrderLevel > > > Next index > > > Close #1 > > End Sub > > > No error is thrown just no return to the listbox (hace checked props, > is set to visible and enabled) > > Any help greatly appreciated > > Mick > Private Type OneProduct
productID As Integer Description As String * 18 Price As Currency QuantityinStock As Integer reOrderLevel As Integer End Type Dim filename As String Dim NumberofRecords As String Is the definition of OneProduct and Private Sub cmdDisplayFile_Click() Dim index As Integer Dim DataToDisplay As String Dim Quantity As String * 4 Dim Price As String * 6 Dim reOrderLevel As String * 3 Dim product As OneProduct filename = txtFileName.Text lstDisplayFile.Clear Open filename For Random As #1 Len = Len(product) For index = 1 To NumberofRecords Get #1, , product Quantity = product.QuantityinStock Price = Format(product.Price, "currency") reOrderLevel = product.reOrderLevel DataToDisplay = product.productID & " " & product.Description _ & " " & Quantity & " " & Price & " " & reOrderLevel 'Assignment to list box here? Next index Close #1 End Sub is the full button code. Dat file exists Thanks a lot > DataToDisplay = product.productID & " " & product.Description _ Use the ListBox's AddItem method to put the DataToDisplay into the list...> & " " & Quantity & " " & Price & " " & reOrderLevel > 'Assignment to list box here? List1.AddItem DataToDisplay Rick Thanks a lot - I really appreciate the help. Have one more problem with
another app but will wait a couple of days - don't want to take up all your time! |
|||||||||||||||||||||||