|
-
Jul 11th, 2009, 01:19 PM
#1
Thread Starter
New Member
[RESOLVED] Loading a Saved text file and ||
I'm using the code below to load contents of network.txt in to a text box
Code:
sFilename = App.Path & "/config/network.txt"
If Dir(App.Path & "/config/") <> "" Then
hFile = FreeFile
Open sFilename For Input As #hFile
Text1.Text = Input$(LOF(hFile), hFile)
Close #hFile
It does this but add two vertical lines in the text box after it. Any Ideas as this is causing a prob when I then use the contents of network.txt as part of a file path ie
Code:
whole_file = GrabFile(Text1.Text & "\trnewsroom\users\users.dat")
I assume what these vertical lines are doing is causing it to got to c:\tr||\trnewsroom\users\users.dat which is causing it to fail.
any help would be greatly appreciated.
-
Jul 11th, 2009, 01:27 PM
#2
Lively Member
Re: Loading a Saved text file and ||
I'm curious what the pipes really are for characters
Can you do this?
MsgBox asc(right(text1.text,1))
This will pop up a number between 0 and 255, which one? If it is 13 or 10, you are also taking a carriage return or line feed which might cause the problem. You need to trim this one then, could be done by:
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 2)
-
Jul 11th, 2009, 01:29 PM
#3
Thread Starter
New Member
Re: Loading a Saved text file and ||
-
Jul 11th, 2009, 01:33 PM
#4
Lively Member
Re: Loading a Saved text file and ||
Thats a linefeed (vbLf), you need to remove it then
-
Jul 11th, 2009, 01:46 PM
#5
Thread Starter
New Member
Re: Loading a Saved text file and ||
Thanks, I found the code below to do that. All works now (prob not the most elegant way of doing it but hey it works).
Code:
Dim strV
strV = Text1.Text
Text2.Text = Replace(strV, Chr(13) & Chr(10), "")
Text1.Text = Text2.Text
-
Jul 11th, 2009, 01:54 PM
#6
Lively Member
Re: [RESOLVED] Loading a Saved text file and ||
It's cleaner then my solution; just removing the last two chars 
You could replace Chr(13) & Chr(10) by vbCrLf or vbNewLine though, it's shorter and faster.
See also; http://www.vbforums.com/showthread.php?t=575726
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|