Hawkeye123456
Programmer
Is there a way to redim a variable array and assign values to it in one sub, and then use the values in a diffrent sub?
This is my code below.
Private Sub Form_Click()
Dim Equ As Long
Dim temp As String
Dim Lines() As String
Dim c As Integer
Dim w As String
Dim U As Integer
SetB 'Sets up the B variable
'Debug.Print B Used for Testing
Open "C:\Program Files\Serv-U\serv-u.ini" For Binary As #1
Do While Not EOF(1)
ReDim Preserve Lines(1 To B) As String
Debug.Print UBound(Lines)
c = c + 1
Line Input #1, temp
Lines(c) = temp
'[GLOBAL] Format of the Desired input
'
If Left(temp, 1) = "[" Then
Equ = InStr(1, temp, "=")
If Equ = o Then GoTo blah
U = U + 1
ReDim Preserve Users(1 To U) As String
'turns [USER=Pub] into Pub
Users(1) = Mid(temp, Equ + 1, Len(temp) - Equ - 1)
lstUsers.AddItem Users(1)
'fso.CreateFolder
End If
blah:
Loop
Close #1
'Used for Debug Purpuses
'For r = 1 To B
' txtOpen = r & " : " & Lines(r) & vbNewLine & txtOpen
'Next
End Sub
Private Sub lstUsers_Click()
Dim a As Integer
For a = 1 To B
If lstUsers.Text = Mid(Lines(a), Equ + 1, Len(Lines(a)) - Equ - 1) Then
txtOpen = Lines(a) & vbNewLine & txtOpen
End If
Next
'lstUsers.Text
End Sub
--------------------------------------------------------
In a module
--------------------------------------------------------
Public Users() As String
Public Lines() As String
Public B As Integer
Sub SetB()
Open "C:\Program Files\Serv-U\serv-u.ini" For Binary As #1
Do While Not EOF(1)
B = B + 1 'Counting the lines in the File
Line Input #1, w
Loop
Close #1
End Sub [sig][/sig]
This is my code below.
Private Sub Form_Click()
Dim Equ As Long
Dim temp As String
Dim Lines() As String
Dim c As Integer
Dim w As String
Dim U As Integer
SetB 'Sets up the B variable
'Debug.Print B Used for Testing
Open "C:\Program Files\Serv-U\serv-u.ini" For Binary As #1
Do While Not EOF(1)
ReDim Preserve Lines(1 To B) As String
Debug.Print UBound(Lines)
c = c + 1
Line Input #1, temp
Lines(c) = temp
'[GLOBAL] Format of the Desired input
'
If Left(temp, 1) = "[" Then
Equ = InStr(1, temp, "=")
If Equ = o Then GoTo blah
U = U + 1
ReDim Preserve Users(1 To U) As String
'turns [USER=Pub] into Pub
Users(1) = Mid(temp, Equ + 1, Len(temp) - Equ - 1)
lstUsers.AddItem Users(1)
'fso.CreateFolder
End If
blah:
Loop
Close #1
'Used for Debug Purpuses
'For r = 1 To B
' txtOpen = r & " : " & Lines(r) & vbNewLine & txtOpen
'Next
End Sub
Private Sub lstUsers_Click()
Dim a As Integer
For a = 1 To B
If lstUsers.Text = Mid(Lines(a), Equ + 1, Len(Lines(a)) - Equ - 1) Then
txtOpen = Lines(a) & vbNewLine & txtOpen
End If
Next
'lstUsers.Text
End Sub
--------------------------------------------------------
In a module
--------------------------------------------------------
Public Users() As String
Public Lines() As String
Public B As Integer
Sub SetB()
Open "C:\Program Files\Serv-U\serv-u.ini" For Binary As #1
Do While Not EOF(1)
B = B + 1 'Counting the lines in the File
Line Input #1, w
Loop
Close #1
End Sub [sig][/sig]