foreach - VB6 For Loop not accepted in one function, works fine in another -
i have old activex component written in vb6 back upwards (don't bother asking modernize it, that's have currently) , weird stuff when compiling next code:
dim connectedprinter printer dim printers() string each connectedprinter in printers printers(ubound(printers)) = connectedprinter.devicename next
all should create list of connected printers. but, when compiling, vb6 tells me that
for each command variable on arrays must variant
what's odd is, in function of same codebase, utilize exact same loop different task (setting current printer als default)
dim pprinter printer each pprinter in printers if (pprinter.devicename = sprintername) set printer = pprinter exit end if next
yet, accepted without hesitation, compiles , demonstrably works in production environment.
what's going on here?
in problem snippet, have local array called printers
hiding printers
collection. can rename local array, or qualify access collection referring vb.printers
.
vb6 foreach activex
No comments:
Post a Comment