Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

File access

Posted on 1998-10-25
5
Medium Priority
?
147 Views
Last Modified: 2010-04-30
Ok this is my prob:
I am creating an application whch acts short of a database.
This app consists of a list box and a text box.
What i want to do is have a topic title in the list box and everytime a topic is selected i want a long secription to appear in the text box.
All of this will be stored in a .dat file and will be accessed through the program.
I want this totally under a .dat file not database or anything else.
My only problem is that i only have enough info to do this using only text boxes and not a list box.
Can anyone help me?
0
Comment
Question by:pestilence
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
kamall earned 200 total points
ID: 1441479
Put 2 list boxes and one text box on your form and copy and paste the following code:

Private Sub Form_Load()
   
    List2.Visible = False
   
    List1.AddItem "Item 1"
    List1.AddItem "Item 2"
    List1.AddItem "Item 3"
   
    List2.AddItem "Text of Item 1"
    List2.AddItem "Text of Item 2"
    List2.AddItem "Text of Item 3"
   
End Sub

Private Sub List1_Click()
   
    Text1.Text = List2.List(List1.ListIndex)

End Sub


If you need more help, just comment me.
Regards
0
 
LVL 7

Expert Comment

by:kamall
ID: 1441480
I forgot to mention that when your program starts, you read the topics from the .dat file and put them in List1, and read the descriptions and put them in List2 by using the .AddItem as I show in my code above.
0
 
LVL 1

Author Comment

by:pestilence
ID: 1441481
Yes i need some more help here...
I have done the same thing with the code you gave me..
It's my mistake i should describe it better, i have the code, and know how to add items on my list box and text box.
My main problem is this:
I want the .dat file to contain data in this style:
[Topic]
1=title
2=title
.
[Description]
1=kdlgkjhgkhgd
2=dlkgkjhgdk
.
I just don't know how to access and read data in this kind of format, since the on-line books don't cover any topic with this kind of subject (as far as i have searched at least).
I am really sorry for messing it a bit :), but thats the main problem i have now.
Can you help me?

0
 
LVL 1

Author Comment

by:pestilence
ID: 1441482
Yes i need some more help here...
I have done the same thing with the code you gave me..
It's my mistake i should describe it better, i have the code, and know how to add items on my list box and text box.
My main problem is this:
I want the .dat file to contain data in this style:
[Topic]
1=title
2=title
.
[Description]
1=kdlgkjhgkhgd
2=dlkgkjhgdk
.
I just don't know how to access and read data in this kind of format, since the on-line books don't cover any topic with this kind of subject (as far as i have searched at least).
I am really sorry for messing it a bit :), but thats the main problem i have now.
Can you help me?

0
 
LVL 7

Expert Comment

by:kamall
ID: 1441483
Of course...
Here is the code:

Open "c:\...." For Input As #1
  Do
    Line Input #1, X$
    If X$ = [Topic] Then
      ....Poulate your List1
    End If
  Loop Until X$ = ""   'Blank line

  Do
    Line Input #1, X$
    If X$ = [Description] Then
      ....Poulate your List2
    End If
  Loop Until X$ = ""   'Blank line
Close 1

For any difficulties, leave me a comment.
Regards.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

636 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