[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Dim strFileList as string()

Posted on 2009-04-10
3
Medium Priority
?
460 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 600 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 200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

649 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