|
-
Jul 10th, 2007, 06:27 AM
#1
Thread Starter
Addicted Member
[RESOLVED] Every new log to new row.
Hi.
Anyone have code, that should save every new text to a new row?
This code saves text to the same row as previous.
Code:
Open "c:\file.txt" for Append as #1
Print #1, strData
Close #1
Miha2c30
-
Jul 10th, 2007, 07:38 AM
#2
Re: Every new log to new row.
Try
Code:
Print #1, strData & vbNewLine
-
Jul 10th, 2007, 09:15 AM
#3
Thread Starter
Addicted Member
Re: Every new log to new row.
No still in the same line
-
Jul 10th, 2007, 09:17 AM
#4
Re: Every new log to new row.
What is strData and how is it created?
-
Jul 10th, 2007, 09:26 AM
#5
Thread Starter
Addicted Member
Re: Every new log to new row.
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
-
Jul 10th, 2007, 11:15 AM
#6
Re: Every new log to new row.
Is strData a combo box control, or a variable containing a string (perhaps selected from a combo box?)?
-
Jul 10th, 2007, 12:10 PM
#7
Thread Starter
Addicted Member
Re: Every new log to new row.
strData is combobox's text, which is not in drop menu
Last edited by Miha2c30; Jul 10th, 2007 at 12:14 PM.
-
Jul 10th, 2007, 12:40 PM
#8
Re: Every new log to new row.
Ok, and you want to dump the contents of your combo box to a text file?
-
Jul 10th, 2007, 12:56 PM
#9
Thread Starter
Addicted Member
Re: Every new log to new row.
Yes
-
Jul 10th, 2007, 01:13 PM
#10
Re: Every new log to new row.
Try
Code:
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
-
Jul 10th, 2007, 01:38 PM
#11
Thread Starter
Addicted Member
Re: Every new log to new row.
Not working ... but it's ok. Anyway, thanks for help. I'll try to find out.
-
Jul 10th, 2007, 01:46 PM
#12
Re: Every new log to new row.
I don't understand. It works fine for me.
What does "not working" mean? Are you getting any data? An error?
-
Jul 10th, 2007, 02:05 PM
#13
Thread Starter
Addicted Member
Re: Every new log to new row.
No, no... Sorry ... 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.
Last edited by Miha2c30; Jul 10th, 2007 at 02:09 PM.
-
Jul 10th, 2007, 02:05 PM
#14
Hyperactive Member
Re: Every new log to new row.
 Originally Posted by Hack
Try .....
Just curious. Why did you set the index. I would have coded
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
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.
I always have to use Print #1, Stuff$; to continue the same line.
Mac
-
Jul 10th, 2007, 02:13 PM
#15
Re: Every new log to new row.
 Originally Posted by Mr.Mac
Just curious. Why did you set the index. I would have coded
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
And you would have been right as well. Both work.
-
Jul 10th, 2007, 02:14 PM
#16
Re: Every new log to new row.
 Originally Posted by Miha2c30
No, no... Sorry  ... 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.
So, you are trying to add something to the combo box and then save it to a text file?
-
Jul 10th, 2007, 02:24 PM
#17
Thread Starter
Addicted Member
Re: Every new log to new row.
No 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).
-
Jul 10th, 2007, 02:36 PM
#18
Re: Every new log to new row.
Then
Code:
Open "c:\file.txt" for Append as #1
Print #1, Text1.Text
Close #1
should work for you.
-
Jul 10th, 2007, 02:39 PM
#19
Hyperactive Member
Re: Every new log to new row.
 Originally Posted by Miha2c30
No  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).
Well, I say that if you run this:
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
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.
Mac
-
Jul 10th, 2007, 02:41 PM
#20
Thread Starter
Addicted Member
Re: Every new log to new row.
Aha It works now. I changed form to TextBox. Thanks for help
-
Jul 10th, 2007, 02:44 PM
#21
Re: [RESOLVED] Every new log to new row.
Not a problem. Anytime, and thank you for marking it resolved.
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
|