Answer to Question #267646 in Visual Basic for ray

Question #267646

how to Create a MainMenu form. On this form implement the following functionality: a) Put a button titled Open Answers File. When this button is clicked; open Answer.txt, and readand store the answers in an array of Strings. Close this file. 


1
Expert's answer
2021-11-17T12:02:42-0500


Create a MainMenu form. On this form implement the following functionality: a) Put a button titled Open Answers File. When this button is clicked; open Answer.txt, and read and store the answers in an array of Strings. Close this file
<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.btnOpenAnswersFile = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        '
        'btnOpenAnswersFile
        '
        Me.btnOpenAnswersFile.Location = New System.Drawing.Point(31, 33)
        Me.btnOpenAnswersFile.Name = "btnOpenAnswersFile"
        Me.btnOpenAnswersFile.Size = New System.Drawing.Size(125, 28)
        Me.btnOpenAnswersFile.TabIndex = 0
        Me.btnOpenAnswersFile.Text = "Open Answers File"
        Me.btnOpenAnswersFile.UseVisualStyleBackColor = True
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(225, 104)
        Me.Controls.Add(Me.btnOpenAnswersFile)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)


    End Sub
    Friend WithEvents btnOpenAnswersFile As System.Windows.Forms.Button


End Class








Imports System.IO




Public Class Form1
    Private answers(100) As String
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load












    End Sub




    Private Sub btnOpenAnswersFile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOpenAnswersFile.Click
        Dim line As String
        Dim FilePath As String = "Answer.txt"
        Using reader As StreamReader = New StreamReader(FilePath)
            ' Read one line from file
            line = reader.ReadLine()
        End Using
        Dim c As Integer = 0
        For Each l In line
            answers(c) = l
            c += 1
        Next
    End Sub
End Class

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS