943,662 Members | Top Members by Rank

Ad:
Jul 26th, 2008
0

read multi line txt.file and display in textbox

Expand Post »
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
Reputation Points: 10
Solved Threads: 0
Light Poster
chern4ever is offline Offline
42 posts
since Jul 2008
Jul 26th, 2008
0

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

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:
VB 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. 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.
Reputation Points: 18
Solved Threads: 7
Junior Poster in Training
dmf1978 is offline Offline
51 posts
since Aug 2006
Jul 26th, 2008
0

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

Use Input statement instead of Line Input

Ex
vb Syntax (Toggle Plain Text)
  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.
Reputation Points: 44
Solved Threads: 101
Posting Pro
selvaganapathy is offline Offline
547 posts
since Feb 2008
Jul 26th, 2008
0

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

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
Reputation Points: 10
Solved Threads: 0
Light Poster
chern4ever is offline Offline
42 posts
since Jul 2008
Jul 27th, 2008
0

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

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
Reputation Points: 10
Solved Threads: 0
Light Poster
chern4ever is offline Offline
42 posts
since Jul 2008
Jul 27th, 2008
0

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

Hi, my above example will solve your problem. just modify the above example.
Reputation Points: 44
Solved Threads: 101
Posting Pro
selvaganapathy is offline Offline
547 posts
since Feb 2008
Jul 27th, 2008
0

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

thanks alot =)
Reputation Points: 10
Solved Threads: 0
Light Poster
chern4ever is offline Offline
42 posts
since Jul 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: string handling
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: how to use a database multiple tables





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC