Solved

Dim strFileList as string()

Posted on 2009-04-10
3
448 Views
Last Modified: 2013-12-25
What does it mean when you dimension a variable as a string followed by ()?  Does this create an array?  How would you convert it back to a simple string?  Here's the code I'm using.  I have not run it yet.  I've never used string() and would like to know what type of variable it creates.
Protected Function DeleteExistingBackup(ByVal strBackupPath As String) As Boolean
 
        Dim strFileList As String()
        Dim strFileName As String
 
 
        If Directory.Exists(strBackupPath) = True Then
 
            strFileList = Directory.GetFiles(strBackupPath, "*.bak")
 
            For Each strFileName In strFileList
                File.Delete(strFileName)
 
            Next
 
            Return True
 
        Else 'Directory does not exist
            Return False
        End If
 
    End Function

Open in new window

0
Comment
Question by:TimSledge
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 13

Accepted Solution

by:
rettiseert earned 150 total points
ID: 24119945
Hi
Dim strFileList As String()
defines an array of strings, but it doesn't create anything yet. The actual array is created in memory somewhere inside Directory.GetFiles(strBackupPath, "*.bak") and its reference is returned to strFileList.

Basically when you use Dim VarName as TypeName() you are defining an array named VarName of TypeName objects, but the size of the array is not known yet. You will be able to define the size of the array later using a Redim statement. For example:

        Dim x As String()   'Defines an array of strings named x.
        Dim ElementsCount As Integer

        ElementsCount = 1 + 1         'Calculate the number of elements that will be in the array.


        ReDim x(0 To ElementsCount - 1)  'The array x defined earlier is created, with 2 elements (indexes 0 and 1)
0
 
LVL 48

Assisted Solution

by:jpaulino
jpaulino earned 50 total points
ID: 24119952
Yes, its an array. You can declare like that or like this:
Dim strFileList () As String
 
0
 
LVL 4

Author Comment

by:TimSledge
ID: 24120099
Thanks to both of you for your answers.
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

724 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