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
Solved

File access

Posted on 1998-10-25
5
142 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
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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…

828 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