Results 1 to 21 of 21

Thread: [RESOLVED] Every new log to new row.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2007
    Location
    Slovenia
    Posts
    131

    Resolved [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

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Every new log to new row.

    Try
    Code:
    Print #1, strData & vbNewLine

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2007
    Location
    Slovenia
    Posts
    131

    Re: Every new log to new row.

    No still in the same line

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Every new log to new row.

    What is strData and how is it created?

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2007
    Location
    Slovenia
    Posts
    131

    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

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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?)?

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jul 2007
    Location
    Slovenia
    Posts
    131

    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.

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Every new log to new row.

    Ok, and you want to dump the contents of your combo box to a text file?

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jul 2007
    Location
    Slovenia
    Posts
    131

    Re: Every new log to new row.

    Yes

  10. #10
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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

  11. #11

    Thread Starter
    Addicted Member
    Join Date
    Jul 2007
    Location
    Slovenia
    Posts
    131

    Re: Every new log to new row.

    Not working ... but it's ok. Anyway, thanks for help. I'll try to find out.

  12. #12
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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?

  13. #13

    Thread Starter
    Addicted Member
    Join Date
    Jul 2007
    Location
    Slovenia
    Posts
    131

    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.

  14. #14
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    Washington DC
    Posts
    314

    Re: Every new log to new row.

    Quote 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

  15. #15
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Every new log to new row.

    Quote 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.

  16. #16
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Every new log to new row.

    Quote 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?

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Jul 2007
    Location
    Slovenia
    Posts
    131

    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).

  18. #18
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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.

  19. #19
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    Washington DC
    Posts
    314

    Re: Every new log to new row.

    Quote 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

  20. #20

    Thread Starter
    Addicted Member
    Join Date
    Jul 2007
    Location
    Slovenia
    Posts
    131

    Re: Every new log to new row.

    Aha It works now. I changed form to TextBox. Thanks for help

  21. #21
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    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
  •  



Click Here to Expand Forum to Full Width