Passing a control array
Working with control arrays in VB3 was frustrating, but with VB4 you can pass a control array as an argument to a function. Simply specify the parameter type as Variant:
AI
AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Source Code
Private Sub Command1_Click(Index As Integer)
GetControls Command1()
End Sub
Public Sub GetControls(CArray As Variant)
Dim C As Control
For Each C In CArray
MsgBox C.Index
Next
End Sub
Also, VB4's control arrays have LBound, Ubound, and Count properties:
If Command1.Count < Command1.Ubound - _
Command1.Lbound + 1 Then _
Msgbox "Array not contiguous"
'Create Dialog Fuction
Dim fOpenDialog As New OpenFileDialog()
'Variable used for retrival of selected files
Dim sFile As String = ""
'Start of width statement
With fOpenDialog
'Set Filter for the selected files
.Filter = "Supported Images|*.bmp;*.jpg|Bitmap Images|*.bmp|JPEG Images|*.jpg|All Files|*.*"
'Set the title of the selected file
.Title = "Select Image to Open"
'Enable Multi-Select
.Multiselect = True
'make sure all selected files exists
.CheckFileExists = True
'Set initial directory to the users desktop
.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory)
'show the open dialog
.ShowDialog()
'get each of the selected file and display it in a msgbox
For Each sFile In .FileNames
'display msgbox the current filepath
MsgBox("File: " & sFile)
Next
'clear the dialog from resorces
.Dispose()
End With
Original Comments (3)
Recovered from Wayback Machine