Question:

How do I have my program (In Visual Basic 2008 Express Edition) Generate a Blank Text File?

by  |  earlier

0 LIKES UnLike

I am trying to figure out how to have my program, I am creating in Visual Basic 2008 Express Edition, Generate a blank/few words txt file in (C:\testfile.txt)

Please help

 Tags:

   Report

2 ANSWERS


  1. With this you can write blank text or any text.

    Try this:

    Place a TextBox and a Button on the form.

    Set the Textbox Multiline = True.

    In This line .F... should read .FileName

    My.Computer.FileSystem.WriteAllText(.F... TextBox1.Text, False)

    Cut and Paste and place in the code pane.

    Public Class Form1

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

            Dim filename As String

            Try

                With SaveFileDialog1

                    .AddExtension = True

                    .CheckPathExists = True

                    .CreatePrompt = False

                    .OverwritePrompt = True

                    .ValidateNames = True

                    .ShowHelp = True

                    .DefaultExt = "txt"

                    .FileName = filename

                    .Filter = _

                    "Text files (*.txt)|*.txt|" & "All files|*.*"

                    .FilterIndex = 1

                    If .ShowDialog() = Windows.Forms.DialogResult.OK Then

                        My.Computer.FileSystem.WriteAllText(.Fil... TextBox1.Text, False)

                    End If

                End With

            Catch ex As Exception

                MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text)

            End Try

        End Sub

    End Class

    : )




  2. Dim CUR_FILE As System.IO.File

    CUR_FILE.Create("c:\New_file.txt")

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.