'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?
Dim myFSO As Scripting.FileSystemObject
Dim myTextStream As Scripting.TextStream
Dim myString As String
Set myFSO = New Scripting.FileSystemObject
If myFSO.FileExists(“filepath.txt”) Then
Set myTextStream = myFSO.OpenTextFile(“filepath.txt”, ForReading)
myString = myTextStream.ReadAll() ‘ file content will be available in myString
Set myTextStream = Nothing
Set myFSO = Nothing
I am writing a java program that needs to execute shell commands, so I wrote a function that would take the command to execute as a string (ie: "mkdir ~/Folder1") and execute that command with the shell. Here is the function:
Runtime run = Runtime.getRuntime();
Process pr = ...
Hi, as I was told that my code doesn’t scale well at all, I thought perhaps I’d try to get a better understanding of interfaces/abstract classes and classes and the relationship between them.
I don’t want at this stage work on a big separate project as I've already got plenty ...
Hi. I have a form with list box : lst_product, datagridview : grd_order and button: btn_addline. lst_product has a list of product ids selected from database (MS Acess 2013) , grd_order is by default empty except for 2 headers and btn_addline adds rows to grd_order.