•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 391,594 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,669 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser:
Views: 3394 | Replies: 27
![]() |
•
•
Join Date: Aug 2005
Posts: 18
Reputation:
Rep Power: 4
Solved Threads: 0
Ok I have a list box and a label...I wish to do the following.
I want to click on a object in the list box and I want information from a .txt file to show up in the label, I need different information for each object in the list box with it clearing each time i click something new in the list box...i have tried several codes and have been trying for hours..anyone able to help me out here
I want to click on a object in the list box and I want information from a .txt file to show up in the label, I need different information for each object in the list box with it clearing each time i click something new in the list box...i have tried several codes and have been trying for hours..anyone able to help me out here
•
•
Join Date: Aug 2005
Posts: 18
Reputation:
Rep Power: 4
Solved Threads: 0
I have this code so far
Now what I want is, I want to click the next object in the listbox and clear the stats.txt file and have like another file come up instead like stats2.txt ect.. Please help me
Private Sub lstteams_Click() Dim FF As Long Dim LineOfText As String FF = FreeFile Open "C:\Documents and Settings\Me\Desktop\New Folder\stats.txt" For Input As #FF Do While Not EOF(FF) Line Input #FF, LineOfText If Len(LineOfText) Then List1.AddItem LineOfText Loop Close #FF End Sub
Now what I want is, I want to click the next object in the listbox and clear the stats.txt file and have like another file come up instead like stats2.txt ect.. Please help me
•
•
Join Date: Aug 2005
Posts: 32
Reputation:
Rep Power: 4
Solved Threads: 1
Hi
I am attaching a sample program which initially loads all the file name into a List Box and then when you click on each item in the List Box it opens up the specified text file and display it in a Label.
Sample code is shown below. Attachment has the complete program.
Marikanna
---------------------------------------------------------------------
Success is a Journey, not a Destination
I am attaching a sample program which initially loads all the file name into a List Box and then when you click on each item in the List Box it opens up the specified text file and display it in a Label.
Sample code is shown below. Attachment has the complete program.
Private Sub List1_Click()
Dim i As Integer
If (FExists("C:\sample\" + List1.Text + ".txt") = True) Then
ReadFromFile ("C:\sample\" + List1.Text + ".txt")
End If
For i = 1 To TotalLine
Label1.Caption = FileText(i)
Next i
End SubMarikanna
---------------------------------------------------------------------
Success is a Journey, not a Destination
•
•
Join Date: Aug 2005
Posts: 18
Reputation:
Rep Power: 4
Solved Threads: 0
Ok I have got it so you click on one and the file.txt opens...but I want it now so you click on the next object in the listbox and it gets rid of file.txt and opens up file2.txt in the label
and another thing...
It will only add one line in the .txt file...say the file looks like this
Testing
Hello This Is A Test
This Should Work
It will only put "This Should Work" down no matter what I do, unless I delete it and move "Hello This Is A Test" down a few lines
and another thing...
It will only add one line in the .txt file...say the file looks like this
Testing
Hello This Is A Test
This Should Work
It will only put "This Should Work" down no matter what I do, unless I delete it and move "Hello This Is A Test" down a few lines
•
•
Join Date: Aug 2005
Posts: 32
Reputation:
Rep Power: 4
Solved Threads: 1
•
•
•
•
Originally Posted by Sharpy
Ok I have got it so you click on one and the file.txt opens...but I want it now so you click on the next object in the listbox and it gets rid of file.txt and opens up file2.txt in the label
and another thing...
It will only add one line in the .txt file...say the file looks like this
Testing
Hello This Is A Test
This Should Work
It will only put "This Should Work" down no matter what I do, unless I delete it and move "Hello This Is A Test" down a few lines
Change all the file path to C:\sample\sample\ . It was previously written C:\sample .
It should work now.
Marikanna
•
•
Join Date: Aug 2005
Posts: 32
Reputation:
Rep Power: 4
Solved Threads: 1
Hi
This will solve the muti line display problem in the label. Still I couldn't get a correct picture of what you are loading in the list box when the form is loaded and what it should do when you click on an item in the list box, basically the relationship between the listbox and the items in the list box.
Quote from your reply
"I need it so you click on the next object in the listbox and it gets rid of the file.txt and puts in file1.txt in the listbox and so on..."
Marikanna
This will solve the muti line display problem in the label. Still I couldn't get a correct picture of what you are loading in the list box when the form is loaded and what it should do when you click on an item in the list box, basically the relationship between the listbox and the items in the list box.
Quote from your reply
"I need it so you click on the next object in the listbox and it gets rid of the file.txt and puts in file1.txt in the listbox and so on..."
Private Sub List1_Click()
Dim i As Integer
Label1.Caption = ""
If (FExists("C:\sample\" + List1.Text + ".txt") = True) Then
ReadFromFile ("C:\sample\" + List1.Text + ".txt")
End If
For i = 1 To TotalLine
Label1.Caption = Label1.Caption + FileText(i) + vbCrLf
Next i
End Sub
Marikanna
•
•
Join Date: Aug 2005
Posts: 18
Reputation:
Rep Power: 4
Solved Threads: 0
Ok thanks that got one problem solved...now..
What that does is, you click on any of the items in the list which I have 15 items in my listbox...it makes the list.txt file appear in the label all fine...what I want is the list.txt file to appear in the label when you click on the 1st item in the list box, but when you click on the 2nd item the list.txt is replaced with list1.txt in the label and so on...hope that clears it up with this
What that does is, you click on any of the items in the list which I have 15 items in my listbox...it makes the list.txt file appear in the label all fine...what I want is the list.txt file to appear in the label when you click on the 1st item in the list box, but when you click on the 2nd item the list.txt is replaced with list1.txt in the label and so on...hope that clears it up with this
•
•
Join Date: Aug 2005
Posts: 32
Reputation:
Rep Power: 4
Solved Threads: 1
Hi
I hope I understood the problem. So you have text files like File1, File2, File3, File4 and in the List box say you have A,B,C,D,E. Now when you click on A, File1 should show up in the label and for B it should show up File2...and so on. I guess this is what the problem is...
Check out the attachement.
Marikanna
I hope I understood the problem. So you have text files like File1, File2, File3, File4 and in the List box say you have A,B,C,D,E. Now when you click on A, File1 should show up in the label and for B it should show up File2...and so on. I guess this is what the problem is...
Check out the attachement.
Marikanna
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Visual Basic 4 / 5 / 6 Marketplace
- Questions about building a system (was: newbie) (Troubleshooting Dead Machines)
- As a newbie, where i should start from in linux? (Getting Started and Choosing a Distro)
- Best free C/C++ compiler for a newbie? (C++)
- help newbie alert needs help with login page (ASP.NET)
- newbie needs help, basic mfc stuff (C++)
- Hello, newbie here... (Geeks' Lounge)
- Book For Newbie (C++)
- Newbie - how do I start C++ programming? (C++)
- PHP newbie, project feasibility (PHP)
- How to network two Win98 machines (Networking Hardware Configuration)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: runtime error#58
- Next Thread: Formatting in Crystal Reports 8.5


Linear Mode