|
-
Nov 26th, 2000, 09:23 PM
#1
Thread Starter
New Member
Is there a function that allows you to check if a control array item exists or not so that you don't need to keep track of what control array items have been loaded?
-
Nov 26th, 2000, 10:27 PM
#2
Addicted Member
If Control().Count<1 Then ControlNotLoaded
-
Nov 27th, 2000, 03:13 AM
#3
Addicted Member
LBound and UBound
Together with the Count function that Xmin mentioned, you can also use the LBound and UBound functions, which return the lowest array index and the highest array index respectively.
So if you have an array of controls and you want to load another, just use UBound + 1.
Code:
Load lblText(lblTest.UBound + 1)
Note that with normal arrays, you can say "UBound(MyTest)", but with control arrays you must use "MyTest.UBound".
Hope this helps.
Shrog
[Edited by Shrog on 11-27-2000 at 03:23 AM]
-
Nov 28th, 2000, 09:55 PM
#4
Thread Starter
New Member
Those methods are good if all of the items are being unloaded but in the program I am working on, pictureboxes etc are not unloaded according to any pattern.
So I might have 10 picture boxes but unload 1, 4 and 9.
Later on, I may need to add new ones or remove the rest. Do I just need to keep some way of tracking what's been loaded? eg in an array that lists the index numbers of the unloaded pages?
-
Nov 29th, 2000, 01:13 AM
#5
Addicted Member
No, there's not really a function for that. If you refer to the control that does not exist, you can trap the resulting error (see example below), but that's about all you can do. You'll probably find that keeping track of the controls yourself is the best bet.
None the less, here is an example of a little function that checks if an instance of "txtData" exists:
Code:
'Check if an instance of the control exists
Private Function ElementExists(vIndex As long) As Boolean
Dim Dummy As String
On Error GoTo ErrorHandle
Dummy = txtData(vIndex).Name
ElementExists = True
Exit Function
ErrorHandle:
ElementExists=false
End Function
Shrog
-
Nov 29th, 2000, 03:52 AM
#6
Addicted Member
Or if you want to keep track of the controls you can define a Boolean array, with its elements referring to each of the controls set at load or unload time so that you know which controls have been unloaded and which loaded by testing the array.
-
Nov 29th, 2000, 04:05 AM
#7
transcendental analytic
You could always use for each statement to enumerate your controls in a controlarray
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|