Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8755801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:55:37+00:00 2026-06-13T13:55:37+00:00

I have this code: Dim FILE_NAME As String = C:\filename.txt Dim objWriter As New

  • 0

I have this code:

      Dim FILE_NAME As String = "C:\filename.txt"

            Dim objWriter As New System.IO.StreamWriter(FILE_NAME)

            objWriter.Write(TextBox1.Text)
            objWriter.Close()

but I want to make something like this (note the objWriter.Write(TextBox.Text) in the text belowe):

      Dim FILE_NAME As String = "C:\filename.txt"

            Dim objWriter As New System.IO.StreamWriter(FILE_NAME)

            objWriter.Write("Lorem ipsum dolor sit amet, consectetur adipiscing objWriter.Write(TextBox1.Text). 
                             Duis dignissim, lacus vel tincidunt pellentesque, lacus ipsum venenatis libero, 
                             faucibus iaculis lectus diam id libero. Mauris interdum augue id lacus
                             commodo consequat. objWriter.Write(TextBox2.Text) et ligula sed sapien")

            objWriter.Close()

Update:

Actual output:

Lorem ipsum dolor sit amet, consectetur adipiscing objWriter.Write(TextBox1.Text). Duis dignissim, lacus vel tincidunt pellentesque, lacus ipsum venenatis libero, commodo consequat. TEST et ligula sed sapien

Wanted output (I would to go at head):

Lorem ipsum dolor sit amet, 
consectetur adipiscing objWriter.
Write(TextBox1.Text). 
Duis dignissim, lacus 
vel tincidunt pellentesque,
 lacus ipsum venenatis libero, 
commodo consequat. TEST et ligula sed sapien
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:55:38+00:00Added an answer on June 13, 2026 at 1:55 pm

    The simplest (but not necessarily ideal) way to do this, in your current code:

    ' UPDATED: Use Environment.NewLine to insert new line breaks:
    
    Dim output As String = "" & _
            "Lorem ipsum dolor sit amet, consectetur adipiscing " & _
            Environment.NewLine & _
            TextBox1.Text & " " & _
            Environment.NewLine & _
            "Duis dignissim, lacus vel tincidunt pellentesque, lacus ipsum venenatis libero, " & _
            "commodo consequat. " & _
            Environment.NewLine & _
            TextBox2.Text + " " & _
            Environment.NewLine & _
            "et ligula sed sapien"
    
    'You are trying to write to root of C here. May require elevated privileges.
    ' Try writing to your user directory, or documents folder. 
    Dim FILE_NAME As String = "C:\filename.txt"
    Dim objWriter As New System.IO.StreamWriter(FILE_NAME)
    objWriter.Write(output)
    objWriter.Close()
    

    Note that you may be running into permission problems attempting to write a file directly to the root of C drive. I had similar issues with this code until I changed the directory path to my home folder, unless I run VS as Administrator (which your users are unlikely to be doing).

    That said, you may actually be asking how to insert the contents of the textbox in read from the streamwriter, in which case you will have to come up with some way to tind the proper insertion point. But this is how you accomplish specifically what you describe in your code above.

    UPDATE:

    You may want to use something like THIS to specify your output directory and file name. Or, of course, use a SaveFileDialog, and allow the user to specify.

    Dim path As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
    Dim FILE_NAME As String = Path & "\MyNextNewFile.txt"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: Dim birthdaystring As String = MonthBirth.SelectedValue.ToString & / & DayBirth.SelectedValue.ToString
I have this code for the settings: Dim settings As XmlWriterSettings = New XmlWriterSettings()
I have this code to create an ATOM feed Dim xmlResult As New StringBuilder
This is the code I have: Sub Main() Dim dts As New DataSet Dim
Let's say I have a string like this. Dim str As String = code
I have this code : void Main() { System.Timers.Timer t = new System.Timers.Timer (1000);
I currently have this code : Private Sub Worksheet_Change(ByVal Target As Range) Dim lastrow
hello I have this code that use to sort a datatable. Dim sortingIndex As
I am printing a receipt with the following code: Dim printFont As New System.Drawing.Font(Courier
I have this code <div id=main style=background:#aaaaaa;float:left;height:160px;margin:5px;position:relative;display:block;width:630px;> <div id=1 class=item style=background:#ffaacc;float:left;width:200px;height:150px;margin:5px;position:absolute;left:0px;top:0px;> </div> <div id=2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.