|
-
Sep 2nd, 2012, 04:58 PM
#1
Thread Starter
New Member
Converting a console code to VB forms
I have the following code (Console mode) I want to convert it to VB Forms, I appreciate your help, I'm not a programmer, I'm a computer network student and I need that code, thanks to any help, here is the code:
Imports System.IO
Module Module1
Sub Main()
Dim answerarray(0 To 5) As String
Dim selection As Integer = 0
Dim studentname As String
Dim Answers As String
Dim Inputfile As StreamReader
Console.WriteLine(" Please enter your name ...")
studentname = Console.ReadLine()
While selection <= 5
Console.WriteLine(" Enter your answer for question (" & selection + 1 & ")")
answerarray(selection) = Console.ReadLine()
selection = selection + 1
End While
Dim change As String
Dim finish As Boolean = False
While finish <> True
Console.WriteLine(" Type 1 to change an answer on a specific question")
Console.WriteLine(" Type 2 to finish the test")
change = Console.ReadLine()
If change = "1" Then
Console.WriteLine(" Please enter question number to be cahnged")
selection = Console.ReadLine()
Console.WriteLine(" What is your new answer?")
answerarray(selection - 1) = Console.ReadLine()
ElseIf change = "2" Then
Console.WriteLine(" Your answer will be saved now....")
Dim myfile As StreamWriter
myfile = File.CreateText("c:\" & studentname & "answers.txt")
selection = 0
While selection <= 5
myfile.WriteLine(answerarray(selection))
selection = selection + 1
End While
myfile.Close()
finish = True
ElseIf change <> "1" Or change <> "2" Then
Console.WriteLine(" Invalid Entry, press to try again...")
change = Console.ReadLine()
End If
End While
Inputfile = File.OpenText("c:\" & studentname & "answers.txt")
Answers = Inputfile.ReadToEnd()
Inputfile.Close()
Console.WriteLine(Answers)
Console.WriteLine(" Press Enter to end the program....")
Console.ReadLine()
End
End Sub
End Module
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|