Solved

File access

Posted on 1998-10-25
5
141 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
  • 3
  • 2
5 Comments
 
LVL 7

Accepted Solution

by:
kamall earned 100 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now