Here’s an interesting one.
I have a page, where I load in some containers. Depending on if its desktop or mobile screen size I have 2 different containers.
card1 and card2 are webcontainers
if mobileversion then
dim c as new card1
else
dim c as new card2
end if
For obvious reasons this will not work as c will not be visible outside the loop , so i tried
dim c as varient
if mobileversion then
c=new card1
else
c= new card2
end if
This also failed so i tried this
dim c as card1
if mobileversion then
c.close
c=nil
c = new card2
end if
Still does not like it
Is there any way to do this, or am i missing something obvious?
The do something part is 2 pages of code and would end up duplicating everything . The errors I get are that it you can not assign a different object type to one thats already defined.
You could do this with an interface with no methods (lets call it GenericCard). If you apply the interface to both classes, you could then dim the variable as GenericCard.
Then later you use IsA and casting to get it back.
Can you make both subclasses of the same ContainerControl and create a common API in the super? Not only would that eliminate your issue, it would make your coding easier.