User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Aug 2005
Posts: 18
Reputation: Sharpy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Sharpy Sharpy is offline Offline
Newbie Poster

Help Newbie Help

  #1  
Aug 8th, 2005
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Posts: 18
Reputation: Sharpy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Sharpy Sharpy is offline Offline
Newbie Poster

Re: Newbie Help

  #2  
Aug 8th, 2005
I have this code so far

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
Reply With Quote  
Join Date: Aug 2005
Posts: 32
Reputation: Marikanna is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
Marikanna Marikanna is offline Offline
Light Poster

Re: Newbie Help

  #3  
Aug 8th, 2005
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.

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 Sub




Marikanna

---------------------------------------------------------------------

Success is a Journey, not a Destination
Attached Files
File Type: zip sample.zip (2.6 KB, 3 views)
Reply With Quote  
Join Date: Aug 2005
Posts: 18
Reputation: Sharpy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Sharpy Sharpy is offline Offline
Newbie Poster

Re: Newbie Help

  #4  
Aug 8th, 2005
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
Reply With Quote  
Join Date: Aug 2005
Posts: 32
Reputation: Marikanna is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
Marikanna Marikanna is offline Offline
Light Poster

Re: Newbie Help

  #5  
Aug 8th, 2005
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
Hi

Change all the file path to C:\sample\sample\ . It was previously written C:\sample .

It should work now.



Marikanna
Reply With Quote  
Join Date: Aug 2005
Posts: 18
Reputation: Sharpy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Sharpy Sharpy is offline Offline
Newbie Poster

Re: Newbie Help

  #6  
Aug 8th, 2005
Yeah that will fix your sample problem, but my problem is, 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...and also with the .txt files it is only puting 1 line in the label
Reply With Quote  
Join Date: Aug 2005
Posts: 32
Reputation: Marikanna is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
Marikanna Marikanna is offline Offline
Light Poster

Re: Newbie Help

  #7  
Aug 9th, 2005
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..."


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
Reply With Quote  
Join Date: Aug 2005
Posts: 18
Reputation: Sharpy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Sharpy Sharpy is offline Offline
Newbie Poster

Re: Newbie Help

  #8  
Aug 9th, 2005
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
Reply With Quote  
Join Date: Aug 2005
Posts: 32
Reputation: Marikanna is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
Marikanna Marikanna is offline Offline
Light Poster

Re: Newbie Help

  #9  
Aug 9th, 2005
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
Attached Files
File Type: zip sample.zip (2.8 KB, 2 views)
Reply With Quote  
Join Date: Aug 2005
Posts: 18
Reputation: Sharpy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Sharpy Sharpy is offline Offline
Newbie Poster

Re: Newbie Help

  #10  
Aug 9th, 2005
ok, that is basically doing the same thing, I click on say "A" then it opens up file1.txt I click on "B" then file1.txt is still open. I want file1.txt to go away and file2.txt to replace it in the label when "B" is clicked on ect.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Visual Basic 4 / 5 / 6 Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum

All times are GMT -4. The time now is 11:30 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC