Re: Trouble With Text Files
First, indent your code, and use code tags.
VB Code:
dim ff as integer
ff = freefile
Open "C:\Irc.txt" For Input As #ff
Do While EOF(1) = False
Line Input #1, sTemp
sTotalString = sTotalString & sTemp
Loop
Close #1
text1.text = sTotalString
You could also read it all at once, with a choice of ways to parse it into lines.
This also counts the lines!
VB Code:
Option Explicit
Private Sub Form_Load()
Dim ff As Integer
Dim strBuff As String
Dim str() As String
ff = FreeFile
Open "C:\Irc.txt" For Input As #ff
strBuff = Input(LOF(ff), ff)
Close #ff
' ----------------- two ways to skin a cat --------------
MsgBox "Lines = " & Len(strBuff) - Len(Replace(strBuff, vbCrLf, "x")) + 1
' -------------------------------------------------------
str() = Split(strBuff, vbCrLf)
MsgBox "There are " & UBound(str) + 1 & " lines in the file"
End Sub
Re: Trouble With Text Files
Why don't you load the entire file at once?
VB Code:
Open "C:\Irc.txt" For Input As #1
text1.text = Input(LOF(1), #1)
Close #1
Re: Trouble With Text Files
You changed it!
If you put the code into the form_activate event, it will already be shown when you add the text. I thought it was on a click of a button.
What does the bat file do? It probably isn't finishing by the time you read irc.txt
Re: Trouble With Text Files
microalps, i tried that it didnt work. dglienna yea it is its echoed into the text file just fine but wont display in the text file..
Re: Trouble With Text Files
i wrote a whole topic about this in the codebank..
dim ff as integer
Open "C:\Irc.txt" For binary As #ff
text1.text = Input(LOF(ff), #ff)
Close #ff
Re: Trouble With Text Files
Re: Trouble With Text Files
It doesn't have time to echo and read at the same time.
Put the echo into the form load, and the text in a command button.
That should be enough time. Otherwise you need to wait a few seconds.
You could also use
VB Code:
"Start MyBatchFile.bat /wait"
Re: Trouble With Text Files
Is the multiline property of text1 set to True? If you don't want it to have any enters then use this code
VB Code:
Open "C:\Irc.txt" For Input As #1
text1.text = Replace(Input(LOF(1), #1), vbCrLf, "")
Close #1
This will remove the enters from the input!
Re: Trouble With Text Files
Yes it was multiple line.
Open "C:\Irc.txt" For Input As #1
text1.text = Replace(Input(LOF(1), #1), vbCrLf, "")
Close #1
Worked!
Re: Trouble With Text Files
You're welcome. Hope my input didn't confuse you though... Good luck on the rest of your project!
Re: Trouble With Text Files
Open "C:\Irc.txt" For Input As #1
text1.text = Replace(Input(LOF(1), #1), vbCrLf, vbnullstring)
Close #1
^^just optimized it a pinch
but seriously you should use binary instead
Open "C:\Irc.txt" For binary As #1
text1.text = Replace(Input(LOF(1), #1), vbCrLf, vbnullstring)
Close #1