'Dim OpenAnswerFile As New OpenFileDialog
Dim strFileName() As String '// String Array.
Dim tempStr As String = "" '// temp String for result.
If OpenAnswerFile.ShowDialog = DialogResult.OK Then '// check if OK was pressed.
strFileName = IO.File.ReadAllLines(OpenAnswerFile.FileName) '// add each line as String Array.
For Each myLine In strFileName '// loop thru Arrays.
tempStr &= myLine & vbNewLine '// add Array and new line.
MsgBox(tempStr) '// display result.
Dim myCoolFile As String = "C:\test.txt" '// your file location.
Dim tempStr As String = IO.File.ReadAllText(myCoolFile) '// read file into a String.
Dim x As Integer = tempStr.Length - 1 '// get String length, Index based, starting at 0 not 1.
Dim myArray(x) As String '// create your String Arrays.
Dim i As Integer = 0 '// Integer used to increase Array #'s.
For Each myChr As Char In tempStr '// loop thru each each character in the String.
myArray(i) = myChr '// add values to each String Array.
i += 1 '// increase count for next Array.
MsgBox(myArray(2)) '// display result for 3rd character.
I am trying to do something almost exactly like this, but i want to load multiple characters. The array is being set-up by a prompt. The variables student and addstudent are defined in this block of code:
Dim Prompt, Title As String
Dim i As Short
Prompt = "Enter your students' names."
AddStudent = InputBox("How many students are in your class?")
If AddStudent > 0 Then ReDim Student(AddStudent)
Student(0) = AddStudent
For i = 1 To UBound(Student)
Title = "Student " & (i + 1)
Student(i) = InputBox(Prompt, Title)
How do i save this then open it so that i can use the defined variables?
Any idea on how to do this?