Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3791

How dynamically create new object inside selec/case or if/then and refer to it ouside these construct

$
0
0

Hi, i have this problem, i must create a new istances of specific webContainer (webCa or webCb or WebCc) in base of a condition… like this( every webContainer has a proprierty named “ID” )

if cond=a i must create dim w as new webCa
if cond=b i must create dim w as new webCb
if cond=c i must create dim w as new webCc

then, in rest part of code (same sub) i must refer to the new object that i have dynamically created

if i use this code, xojo say me that the object that i refere is not exists (this is scope problem of my code )

Select case tipo.Uppercase
case "A"   
  dim w as new webCa
case "B" 
  dim w as new WebCb
case "C"   
  dim w as new WebCc
end select 

w.EmbedWithin(wpMain,10,10,w.Width+30,w.Height+30)


when i try to refer to w (w.EmbedWithin(wpMain,10,10,w.Width+30,w.Height+30) ) out of the select case xojo say me the w is not exist, there is a scope problem, but i cant create the object before check the condition, and i cant create e generic webcontainer before check condition and assign to it the instance of new webcontainer (w) that i have create in select/case costruct because in this case the generic webContainer hasen’t the specifics proprierty (ID) of webCotainer that i assign to it (and xojo say me that there is an error )

Does anyone know what the way out could be?

25 posts - 7 participants

Read full topic


Viewing all articles
Browse latest Browse all 3791

Trending Articles