I have a routine in a module that accepts an array as a parameter and was wondering if the way I have it coded will cause memory leaks? As a side question, does VB have a way to tell if dynamic memory is being recovered?
Thanks in advance.
the definition
The callerCode:Public Sub dbExist(matches() As String, arrSize As Integer) Dim spath As String, fname As String Dim idx As Integer: idx = 0 spath = IIf(Right(App.Path, 1) = "\", App.Path, App.Path & "\") fname = Dir(spath, vbDirectory) While fname <> "" If fname <> "." And fname <> ".." Then If (GetAttr(spath & fname) And vbDirectory) <> vbDirectory Then If Right(LCase(fname), 3) = '".mdb" Then ReDim Preserve matches(idx + 1) matches(idx) = fname idx = idx + 1 End If End If End If fname = Dir Wend arrSize = idx End Sub
Code:Private Sub Form_Load() Dim dbs() As String Dim dsize As Integer dbExist dbs, dsize If dsize > 0 Then dbFiles.Text = dbs(0) For i = 0 To dsize - 1 dbFiles.AddItem dbs(i) Next i Erase dbs End If End Sub




Reply With Quote