CopyTextArray




Public Sub ShowArrayValues()
'handle the errors

On Error Goto 55
'Takes the values of the arrays stored in C:\test.txt

ClearLists
Dim str1 As String
Dim str2 As String
Dim int3() As Integer
Dim int4() As Currency
Dim int5 As Integer
'this integer counts each array

Dim intCount As Long
'open file for input

Open "C:\test.txt" For Input As #1
'gets the array values, stores as variables

Do While Not EOF(1)
're-declare the variables

ReDim Preserve int4(intcount)
ReDim Preserve int5(intcount)
'input the arrays into the variables

Input #1, str1, str2, int4(intcount), int5(intcount)
lst1.AddItem str1
lst2.AddItem str2
lst3.AddItem int4(intcount)
lst4.AddItem int5(intcount)
intcount = intcount + 1
Loop
Close #1
Exit Sub
'error handling code

55
MsgBox "Error Number: " & Err.Number & vbCrLf & _
Err.Description, vbExclamation, "An Error Has Occurred"
End Sub











( copytextarray.html )- by Paolo Puglisi - Modifica del 17/12/2023