Hi.
Anyone have code, that should save every new text to a new row?
This code saves text to the same row as previous.
Miha2c30Code:Open "c:\file.txt" for Append as #1
Print #1, strData
Close #1
Printable View
Hi.
Anyone have code, that should save every new text to a new row?
This code saves text to the same row as previous.
Miha2c30Code:Open "c:\file.txt" for Append as #1
Print #1, strData
Close #1
TryCode:Print #1, strData & vbNewLine
No :( still in the same line
What is strData and how is it created?
It's a combobox (for browser)
Here's my code:
Code:Private Sub cmdSearch_Click()
wWeb.Navigate cboURL.Text
Open "C:\MPLogs.txt" For Output As #1
Print #1, cboURL.Text & vbNewLine
Close #1
End Sub
Is strData a combo box control, or a variable containing a string (perhaps selected from a combo box?)?
strData is combobox's text, which is not in drop menu
Ok, and you want to dump the contents of your combo box to a text file?
Yes :)
TryCode:Private Sub Command1_Click()
Dim i As Long
Open "c:\URL.txt" For Output As #1
For i = 0 To cboURL.ListCount - 1
cboURL.ListIndex = i
Print #1, cboURL.List(cboURL.ListIndex)
Next
Close #1
End Sub
Not working ... but it's ok. Anyway, thanks for help. I'll try to find out.
I don't understand. It works fine for me.
What does "not working" mean? Are you getting any data? An error?
No, no... Sorry :blush: ... It works, but mine ComboBox's list was empty, but I wanted to log ComboBox's text, not list. Maybe it's easier, if I change ComboBox with TextBox. So, I need to log text from textbox.
Just curious. Why did you set the index. I would have codedQuote:
Originally Posted by Hack
But I'm even more curious about the original problem. I have never seen the case where Print #1, Stuff$ did not create a new line.Code:Private Sub Command1_Click()
Dim i As Long
Open "c:\URL.txt" For Output As #1
For i = 0 To cboURL.ListCount - 1
Print #1, cboURL.List(i)
Next
Close #1
End Sub
I always have to use Print #1, Stuff$; to continue the same line.
Mac
And you would have been right as well. Both work. :DQuote:
Originally Posted by Mr.Mac
So, you are trying to add something to the combo box and then save it to a text file?Quote:
Originally Posted by Miha2c30
No :lol: I'm creating a Web Browser and I have a TextBox, where people insert an URL. I want that URL saves to a file (txt).
Thenshould work for you.Code:Open "c:\file.txt" for Append as #1
Print #1, Text1.Text
Close #1
Well, I say that if you run this:Quote:
Originally Posted by Miha2c30
and you do not get two lines in the file, then something is VERY wrong with your system. It is impossible that you are getting the error you describe.Code:Dim LogThis As String
Open "MyLog.txt" For Append As #1
LogThis = "line one"
MsgBox LogThis
Print #1, LogThis
Close #1
Open "MyLog.txt" For Append As #1
LogThis = "a different line"
MsgBox LogThis
Print #1, LogThis
Close #1
End Sub
Mac
Aha :) It works now. I changed form to TextBox. Thanks for help ;)
Not a problem. Anytime, and thank you for marking it resolved. :thumb: