Solved

Not declared

Posted on 2006-07-21
2
226 Views
Last Modified: 2010-04-23
Hi,

I get the following error about not being declared;

lstFilesFound

on line that reads

lstFilesFound.Add(f)

Here is the code...

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        searchFiles()

    End Sub

    Private Sub searchFiles()
        Try
            Dim drives() As String
            Dim rootfolders() As String
            Dim d As String
            Dim f As String
            drives = System.IO.Directory.GetLogicalDrives()
            For drivecount As Integer = 0 To drives.Length - 1
                rootfolders = System.IO.Directory.GetDirectories(drives(drivecount))
                For rootFolderCount As Integer = 0 To rootfolders.Length - 1
                    DirSearch(rootfolders(rootFolderCount))
                Next
            Next
        Catch ex As Exception

        End Try
    End Sub

    Sub DirSearch(ByVal sDir As String)
        Dim d As String
        Dim f As String
        Try
            For Each d In System.IO.Directory.GetDirectories(sDir)
                For Each f In System.IO.Directory.GetFiles(d, "*.Txt")
                    lstFilesFound.Add(f)
                Next
                DirSearch(d)
            Next
        Catch excpt As System.Exception
            Debug.WriteLine(excpt.Message)
        End Try
    End Sub
End Class
0
Comment
Question by:nickmarshall
  • 2
2 Comments
 
LVL 23

Expert Comment

by:apresto
ID: 17153910
Hi nickmarshall,

You havent declared lstFilesFound, what should it be, an arraylist?

if so add it at the top where you have the other DIM lines, Dim lstFilesFound as ArrayList or something similar

Apresto
0
 
LVL 23

Accepted Solution

by:
apresto earned 125 total points
ID: 17153936
>>>lstFilesFound

unless its a control on your form, like a list box or something, make sure you have declared it in the class, just do Alt + f for 'lstFilesFound'
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question