Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help With Variable Not Defined
Message
From
29/06/2001 12:52:16
 
 
To
29/06/2001 11:57:38
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00525229
Message ID:
00525253
Views:
21
>Hi All,
>
>Here is the old VFPer trying to learn to spell VB again. I'm trying to write an app. to read a file from the dialog box and select it. I got the following code from "Mastering VBA 6" Sybex. I Would really appricate some help with this. TIA.
>
>Regards,
>
>Paige
>
>
>Option Explicit
>Option Base 1
>
>Private Sub UserForm_Initialize()
>'
> Dim strFileArray() As String
> Dim strFFile As String
> Dim intCount As Integer
>
>'
> strFFile = Dir("C:\My Documents\*.txt")
> intCount = 1
>'
> Do While strFFile <> ""
> If strFFile <> "." And strFFile <> ".." Then
> ReDim Preserve strFileArray(intCount)
> strFileArray(intCount) = strFFile
> intCount = intCount + 1
> strFFile = Dir()
> End If
>'
> Loop
>'
>' I get a "Variable not defined" error on the following line:
>
> lstFiles.List() = strFileArray
>
>' Any suggestions? When I create a "Dim lstFiles As String" I get an error there
>'
>End Sub
>'
>
>
>Private Sub CommandButton2_Click()
> If lstFiles.Value <> "" Then Documents.Open _
> FileName:=" C:\My Documents\" & lstFiles.Value
>'
>End Sub

Are you declaring lstFiles anywhere? If you declare it as a String, then the line lstFiles.List() = strFileArray will not work, because a String does not have a List() method, and you cannot assign a value to a method, which is what that line is doing. Remember that strFileArray is an array, and you cannot assign an array object to a string object.
Andres M. Chiriboga, MCSE, MCP+I
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform