Question

Visual Basic File access Create a form that allow users to enter information (either through text...

Visual Basic

File access

Create a form that allow users to enter information (either through text boxes or user input). You decide what you want the users to enter. Use the information entered by the user to create a file that contains the information entered.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

In case of any query do comment. Please rate answer as well. Thanks

Code:

==Form1.vb==

Imports System.IO

Public Class Form1

    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click

        'StreamWrite is used to write lines to the file opened by File.CreateText

        Using writer As StreamWriter = File.CreateText("C:\input.txt")

            'Write the content of a text box

            writer.WriteLine(txtInput.Text)

        End Using

   End Sub

End Class

===from1.designer.vb===

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _

Partial Class Form1

    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.

    <System.Diagnostics.DebuggerNonUserCode()> _

    Protected Overrides Sub Dispose(ByVal disposing As Boolean)

        Try

            If disposing AndAlso components IsNot Nothing Then

                components.Dispose()

            End If

        Finally

            MyBase.Dispose(disposing)

        End Try

    End Sub

    'Required by the Windows Form Designer

    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer

    'It can be modified using the Windows Form Designer.

    'Do not modify it using the code editor.

    <System.Diagnostics.DebuggerStepThrough()> _

    Private Sub InitializeComponent()

        Me.Label1 = New System.Windows.Forms.Label()

        Me.txtInput = New System.Windows.Forms.TextBox()

        Me.btnSave = New System.Windows.Forms.Button()

        Me.SuspendLayout()

        '

        'Label1

        '

        Me.Label1.AutoSize = True

        Me.Label1.Location = New System.Drawing.Point(57, 88)

        Me.Label1.Name = "Label1"

        Me.Label1.Size = New System.Drawing.Size(118, 20)

        Me.Label1.TabIndex = 0

        Me.Label1.Text = "Enter text here:"

        '

        'txtInput

        '

        Me.txtInput.Location = New System.Drawing.Point(212, 74)

        Me.txtInput.Multiline = True

        Me.txtInput.Name = "txtInput"

        Me.txtInput.Size = New System.Drawing.Size(241, 87)

        Me.txtInput.TabIndex = 1

        '

        'btnSave

        '

        Me.btnSave.Location = New System.Drawing.Point(218, 251)

        Me.btnSave.Name = "btnSave"

        Me.btnSave.Size = New System.Drawing.Size(187, 39)

        Me.btnSave.TabIndex = 2

        Me.btnSave.Text = "Save to File"

        Me.btnSave.UseVisualStyleBackColor = True

        '

        'Form1

        '

        Me.AutoScaleDimensions = New System.Drawing.SizeF(9.0!, 20.0!)

        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font

        Me.ClientSize = New System.Drawing.Size(800, 450)

        Me.Controls.Add(Me.btnSave)

        Me.Controls.Add(Me.txtInput)

        Me.Controls.Add(Me.Label1)

        Me.Name = "Form1"

        Me.Text = "Form1"

        Me.ResumeLayout(False)

        Me.PerformLayout()

    End Sub

    Friend WithEvents Label1 As Label

    Friend WithEvents txtInput As TextBox

    Friend WithEvents btnSave As Button

End Class

=======screen shot of the code====

Output:

Add a comment
Know the answer?
Add Answer to:
Visual Basic File access Create a form that allow users to enter information (either through text...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT