GPWiki.org
GPWiki.org
It is currently Sun May 19, 2013 2:51 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Hi. Array & Classes
PostPosted: Thu Jan 07, 2010 10:41 am 
hi im coming from a 10 year hiatus on vb programming and programing in general. I need help with this.

Function InitAnimalRefs() As Integer
Dim i As Integer

InitColors
ReDim arAnimal(0 To 3)

For i = 0 To UBound(arAnimal)
Set arAnimal(i) = New clsAnimalRef
Next i


arAnimal(0).InitAnimalRef 20, "Donkey", aRed
arAnimal(1).InitAnimalRef 15, "Cat", aYellow
arAnimal(2).InitAnimalRef 5, "Mouse", aOrange
arAnimal(3).InitAnimalRef 25, "Cow", aBlue

InitAnimalRefs = UBound(arAnimal)

End Function

I dont know how to properly instantiate a new object array as the clsAnimalRef class.


Top
  
 
 Post subject:
PostPosted: Thu Jan 07, 2010 10:33 pm 
Octogenarian

Joined: Mon Oct 25, 2004 11:21 pm
Posts: 89
Try this

Dim arAnimal() As clsAnimalRef


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 08, 2010 12:59 pm 
Funky Monkey

Joined: Mon Aug 16, 2004 2:48 pm
Posts: 1604
Location: Minneapolis, MN USA
Alex ...

Are you getting a specific error when you run your code? Which line is highlighted and what is the error?

I think you may need parens after the class name when instantiating a new object. (It's been quite a while since I switched from VB6 to VB.Net, so I'm fuzzy on how the "old way" worked.)

Like this: Set arAnimal(i) = New clsAnimalRef( )

Also -- make sure of the scope of your Class ... is it a valid class within that function?

-Bryk

_________________
www.mwgames.com ... Dicey Curves, Space Mission, Jump Gate, Gem Raider, DareBase, Castle Danger, Keeps & Moats Chess


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Baidu [Spider] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group