Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Lists Loading

Posted on 2005-04-13
Medium Priority
Last Modified: 2011-09-20

i have two lists the first inclueds six cars and the second list will display the parts for that car . so each time choose can only
view a list for one car only. then click a button to go to next screen after choosing a part from list.

Then read in from a sequential text file info on that part and print info of list items chosen and part info in a picture box on the screen .  

a idea of how text file looks : "ford","2254",Flywheel","330000"(car name, price, part , total value) i only want to display info on selected items from list not whole file .

i dont know how to do this and make it work.  
Question by:AlanPockley

Expert Comment

ID: 13772007
There are many ways to do this, but two ways I can think of are firstly that you create a data structure e.g.

Private Type CarPartRecord

   Brand as string
   PartNo as long
   PartDesc as string

End Type

Then you would need to create an array to read this information from the file into it.

Now if you take a more structured approach and use ADO disconnected recordsets you can save on grief and extra coding.
You could simply create a drs to hold your car parts and then save it as an ADO ADTG to hard disk (similar to file, but saving and reading it back are less grief than creating arrays and messing with UDTs). e.g.

Dim adoRs As ADODB.Recordset
    ' Build ADO Rs Error Structure
    Set adoRs = New ADODB.Recordset
    With adoRs

        .CursorLocation = adUseClient
        .LockType = adLockBatchOptimistic
        .Fields.Append "BrandName", adVarChar, 255, adFldMayBeNull
        .Fields.Append "PartDesc", adVarChar, 255, adFldMayBeNull
        .Fields.Append "PartNo", adLongVarWChar, 250000, adFldMayBeNull

   End With

Now you would use ADO's .AddNew and .Update to add or amend records.

To save it to HardDisk simply use .Save strFilePathName, adPersistADTG

Then when you want to open it from Hard Disk simply use

        Set adoRs = New ADODB.Recordset
        adoRs.CursorLocation = adUseClient
        adoRs.Open strFilePathName

To search the part number or name use the .Filter or .Find method.
LVL 86

Accepted Solution

Mike Tomlinson earned 2000 total points
ID: 13772010
How big is the text file?  If it isn't too big then we can walk the file and build a set of collections that correspond to the parts belonging to each car, populating the car list as we go.  Then when a car is selected, we repopulate the parts list from the corresponding collection in memory.

If you post some more entries from the text file, perhaps at least 3 parts from each car, then I can give you an example.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 7 hours left to enroll

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question