read multi line txt.file and display in textbox

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2008
Posts: 25
Reputation: chern4ever is an unknown quantity at this point 
Solved Threads: 0
chern4ever chern4ever is offline Offline
Light Poster

read multi line txt.file and display in textbox

 
0
  #1
Jul 26th, 2008
i would like to read some data and display it in textbox.

my example of data in my txt file are:
"moviename1", "movieshowtime1"
"moviename2", "movieshowtime2"

when i display it in text box, it shows exactly like above.
i want it to display without the quotes.
how i can achive tat?
moviename1, movieshowtime1
moviename2, movieshowtime2

this is my code
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Private Sub Command1_Click()
  2.  
  3. Dim dText As String, dNextLine As String, lLineCount As Long
  4. lLineCount = 1
  5.  
  6. Open "C:\Users\Chern\CINEMA\reserve.txt" For Input As #1
  7. Do While Not EOF(1)
  8. Line Input #1, dNextLine
  9. dText = dText & dNextLine & vbCrLf
  10. Loop
  11. Text1.Text = dText
  12.  
  13. End Sub
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 51
Reputation: dmf1978 is an unknown quantity at this point 
Solved Threads: 7
dmf1978's Avatar
dmf1978 dmf1978 is offline Offline
Junior Poster in Training

Re: read multi line txt.file and display in textbox

 
0
  #2
Jul 26th, 2008
Hi,
Use the Replace function.
The syntax is
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Replace(string, find, replace)
Doing it in your code:
  1. Private Sub Command1_Click()
  2.  
  3. Dim dText As String, dNextLine As String, lLineCount As Long
  4. lLineCount = 1
  5.  
  6. Open "C:\Users\Chern\CINEMA\reserve.txt" For Input As #1
  7. Do While Not EOF(1)
  8. Line Input #1, dNextLine
  9. dNextLine = Replace(dNextLine, Chr$(34), "")
  10. dText = dText & dNextLine & vbCrLf
  11. Loop
  12. Text1.Text = dText
  13.  
  14. End Sub
Chr$(34) is the " char.

Hope it helps.
-- Martín
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 509
Reputation: selvaganapathy is an unknown quantity at this point 
Solved Threads: 88
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro

Re: read multi line txt.file and display in textbox

 
0
  #3
Jul 26th, 2008
Use Input statement instead of Line Input

Ex
  1. Private Sub Command1_Click()
  2. Dim dText As String
  3. Dim sString1 As String, sString2 As String
  4.  
  5. Open "C:\Users\Chern\CINEMA\reserve.txt" For Input As #1
  6. Do While Not EOF(1)
  7. Input #1, sString1, sString2
  8. dText = dText & sString1 & ", " & sString2 & vbCrLf
  9. Loop
  10. Text1.Text = dText
  11. End Sub
Last edited by selvaganapathy; Jul 26th, 2008 at 1:59 pm.
KSG
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 25
Reputation: chern4ever is an unknown quantity at this point 
Solved Threads: 0
chern4ever chern4ever is offline Offline
Light Poster

Re: read multi line txt.file and display in textbox

 
0
  #4
Jul 26th, 2008
i have another problem, i wan it to appear like this
moviename1, movieshowtime1
moviename2, movieshowtime2

but it wont jump to second line, it stick together
moviename1,movieshowtime1moviename2,movieshowtime2

thanks for helping
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 25
Reputation: chern4ever is an unknown quantity at this point 
Solved Threads: 0
chern4ever chern4ever is offline Offline
Light Poster

Re: read multi line txt.file and display in textbox

 
0
  #5
Jul 27th, 2008
thanks i solve my previous problem.
now another problem.
in my txt file :
moviename1, movieshowtime1
moviename2, movieshowtime2

i want to show only this in a text box. is that possible?
moviename1
moviename2
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 509
Reputation: selvaganapathy is an unknown quantity at this point 
Solved Threads: 88
selvaganapathy's Avatar
selvaganapathy selvaganapathy is offline Offline
Posting Pro

Re: read multi line txt.file and display in textbox

 
0
  #6
Jul 27th, 2008
Hi, my above example will solve your problem. just modify the above example.
KSG
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 25
Reputation: chern4ever is an unknown quantity at this point 
Solved Threads: 0
chern4ever chern4ever is offline Offline
Light Poster

Re: read multi line txt.file and display in textbox

 
0
  #7
Jul 27th, 2008
thanks alot =)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC