excel - User-Defined Object In Array VBA -


as subject line states, trying store objects of class wrote array. vba giving me frustrating error:

'object variable or block variable not set'

i'm pretty sure defining object correctly, , local variables show object of defined type , of it's fields filled in, can't figure out issue is.

dim type1(2 250) myclass dim type2(2 250) myclass dim type3(2 250) myclass dim temp_obj myclass dim foo string  = 2 250     set temp_obj = new myclass     temp_obj         .field1 = worksheets("sheet1").rows(i).columns(2).value         .field2 = worksheets("sheet1").rows(i).columns(3).value         .field3 = worksheets("sheet1").rows(i).columns(4).value         .field4 = worksheets("sheet1").rows(i).columns(5).value     end     foo = worksheets("sheet1").rows(i).columns(1).value     if foo = "type1"         type1(i) = temp_obj     elseif foo = "type2"         type2(i) = temp_obj     elseif foo = "type3"         type3(i) = temp_obj     end if next 

my class looks this:

private pfield1 single private pfield2 integer private pfield3 string private pfield4 string  public property field1() single     field1 = pfield1  end property  public property field2() integer     field2 = pfield2 end property  public property field3() string     field3 = pfield3 end property  public property field4() string     field4 = pfield4 end property  public property let field1(p single)     pfield1 = p end property  public property let field2(p integer)     pfield2 = p end property  public property let field3(p string)     pfield3 = p end property  public property let field4(p string)     pfield4 = p end property 

try change @ bottom:

if foo = "type1"     set type1(i) = temp_obj elseif foo = "type2"     set type2(i) = temp_obj elseif foo = "type3"     set type3(i) = temp_obj end if 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -