-
Hi Guys
I have been trying to create an array of controls which is passed to a function to check each controls properties.
Following is a sample of the code I have written:
Dim BoolReturn As Boolean
Dim TextBoxName As Variant
Dim TextBoxNameArray(0 To 5) As Control
' Build up the array of text boxs to be checked
TextBoxNameArray(0) = DealerName ' Dealer Name
TextBoxNameArray(1) = DealerContact ' Dealer Contact
TextBoxNameArray(2) = PhoneNumber ' Dealer Phone Number
TextBoxNameArray(3) = FaxNumber ' Dealer Fax Number
TextBoxNameArray(4) = CompanyName ' End User Company Name
TextBoxNameArray(5) = PhoneNumber1 ' End User Phone Number
' m_file holds the location for the asmlic.exe executable
m_file = "\\Admax\autosm\authcode\asmlic.exe "
' a_file is used to store the temporary authorisation code piped from asmlic.exe
a_file = "\\Admax\autosm\authcode\authcode.txt"
' Iterate through each TextBoxName element in TextBoxNameArray.
For Each TextBoxName In TextBoxNameArray
' This function tests that all the necessary details have been filled in correctly
BoolReturn = Functions.TestFieldValue(TextBoxName, "Dealer Name")
' If the BoolReturn is false i.e. the text box has not correctly filled in, exit the sub
' routine and set the focus to the appropriate text box.
If Not BoolReturn Then
Exit Sub
TextBoxName.SetFocus
End If
Next
When I try and use the control name to populate the TextBoxNameArray array, it uses the default property of the control rather than a ref to the control name itself.
Can any body help?
Thanks in advance.
-
You have to use the Set keyword:
Code:
' Build up the array of text boxs to be checked
Set TextBoxNameArray(0) = DealerName ' Dealer Name
Set TextBoxNameArray(1) = DealerContact ' Dealer Contact
'and so on
Good luck!