Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Writing multiple text to a text file  (Read 3233 times)

0 Members and 1 Guest are viewing this topic.

Little Marine

    Topic Starter


    Intermediate

    Thanked: 1
    Writing multiple text to a text file
    « on: November 20, 2009, 04:55:30 AM »
    Hello, I am trying to write multiply text from textboxes. I am using this code for a single textbox. Can someone help me to modify this code to write from multiply textboxes.  Thank you.
    Dim FILE_NAME As String = "C:\ test2.txt"
    If System.IO.File.Exists(FILE_NAME) Then
    objWriter.Write(Textbox1.Text)
    objWriter.Close()
    MsgBox("Text written to file")
    Else
        MsgBox("File doesn't exist")
    End if

    Linux711



      Mentor

      Thanked: 59
      • Yes
      • Programming Blog
    • Certifications: List
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    Re: Writing multiple text to a text file
    « Reply #1 on: November 21, 2009, 01:29:41 AM »
    Quote
    I am trying to write multiply text from textboxes.
    . . .
    Quote
    to write from multiply textboxes.

    Do you mean multiple?


    If you do then


    Can't you just make another textbox and add another line?
    Code: [Select]
    Dim FILE_NAME As String = "C:\ test2.txt"
    If System.IO.File.Exists(FILE_NAME) Then
    objWriter.Write(Textbox1.Text)
    objWriter.Write(Textbox2.Text)
    objWriter.Close()
    MsgBox("Text written to file")
    Else
        MsgBox("File doesn't exist")
    End if


    else


    Then you must want to multiply it. Just add another textbox and use this code.
    Code: [Select]
    Dim FILE_NAME As String = "C:\ test2.txt"
    If System.IO.File.Exists(FILE_NAME) Then
    objWriter.Write(Val(Textbox1.Text) * Val(Textbox2.Text))
    objWriter.Close()
    MsgBox("Text written to file")
    Else
        MsgBox("File doesn't exist")
    End if


    end if

    If I don't have it right then

    Could you explain it more clearly?

    end if
    YouTube

    "Genius is persistence, not brain power." - Me

    "Insomnia is just a byproduct of, "It can't be done"" - LaVolpe

    mroilfield



      Mentor
    • Thanked: 42
      • Yes
      • Yes
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 11
    Re: Writing multiple text to a text file
    « Reply #2 on: November 21, 2009, 02:08:01 AM »
    end if

    If I don't have it right then

    Could you explain it more clearly?

    end if

    What's with the "end if"
    You can't fix Stupid!!!

    Linux711



      Mentor

      Thanked: 59
      • Yes
      • Programming Blog
    • Certifications: List
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    Re: Writing multiple text to a text file
    « Reply #3 on: November 21, 2009, 02:15:38 AM »
    I was trying to make the whole thing like a program.
    YouTube

    "Genius is persistence, not brain power." - Me

    "Insomnia is just a byproduct of, "It can't be done"" - LaVolpe

    mroilfield



      Mentor
    • Thanked: 42
      • Yes
      • Yes
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 11
    Re: Writing multiple text to a text file
    « Reply #4 on: November 21, 2009, 03:05:52 AM »
    I was trying to make the whole thing like a program.

    Why not just give a straight answer instead so that there is less chance for confusion?
    You can't fix Stupid!!!

    Little Marine

      Topic Starter


      Intermediate

      Thanked: 1
      Re: Writing multiple text to a text file
      « Reply #5 on: November 23, 2009, 05:00:31 AM »
      Thanks all who replied. My problem is solved