• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 148
  • Last Modified:

File access

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
pestilence
Asked:
pestilence
  • 3
  • 2
1 Solution
 
kamallCommented:
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
 
kamallCommented:
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
 
pestilenceAuthor Commented:
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
 
pestilenceAuthor Commented:
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
 
kamallCommented:
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.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now