all groups > vb.net upgrade > november 2006 >
You're in the

vb.net upgrade

group:

Control Array upgrade FIXIT



Control Array upgrade FIXIT EnVeeTee
11/11/2006 12:00:00 AM
vb.net upgrade: Just curious...

I have a large '6 app and ran it through the CodeAdvisor. Most issues seem
dealable with, however...

I pass a LOT of Control Arrays through to Class modules. CodeAdvisor squeals
about late binding, so how could I recode this code section...


..
..
Call ChangeAllColours(lblCtrlArray,vbBlue)
..
..


In Class

Sub ChangeAllColours(objLabel as Object, ColourToChangeTo&)

for n=0 to objLabel.count
objlabel(n).color=colourtochangeto&
next n

end sub


CodeAdvisor does not like the ...objLabel as Object... and complains about
late binding

Thanks for any tips


Re: Control Array upgrade FIXIT Jay B. Harlow
11/11/2006 10:38:22 AM
EnVeeTee,
[quoted text, click to view]
To avoid a late binding warning you need to use early binding. To use early
binding you need to explicitly define the types.


[quoted text, click to view]
Appears to be an array of labels, so you could use something like:


[quoted text, click to view]


I would consider an array of Controls instead:

[quoted text, click to view]

NOTE: The above are the VB.NET code...

--
Hope this helps
Jay B. Harlow
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net


[quoted text, click to view]
AddThis Social Bookmark Button