joe_pool_is Posted February 20, 2004 Posted February 20, 2004 I want to make this as generic as possible, so I'll use crayons as an example: class Crayon public Number as short = 0 public Name as string = "" public Manufacturer as string = "" end class private Color(64) as Crayon Now, how do I declare my Color() array as an object so that I can read and set my variables? This is probably very basic, but it is so basic that I can't find any help on it anywhere. Thanks in advance! Quote Avoid Sears Home Improvement
Leaders dynamic_sysop Posted February 20, 2004 Leaders Posted February 20, 2004 i wouldn't use the Word " Color " to describe an instance of something , as Color is already a Class in .net. but to create an instance of your array ... Class Crayon Public Number As Short = 0 Public Name As String = "" Public Manufacturer As String = "" End Class Private col(65) As Crayon Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click col(0) = New Crayon() With col(0) .Manufacturer = " microsoft " .Name = " bill gates " End With End Sub Quote
joe_pool_is Posted February 20, 2004 Author Posted February 20, 2004 Cute kiddos, Sysop. I see your point. So basically, I have to initialize every element of the array first. I guess that's what I needed to know. Thanks a million! ~Joe Quote Avoid Sears Home Improvement
tate Posted February 20, 2004 Posted February 20, 2004 You don't have to initialize every element of an array unless you know exactly what the array will hold. If you don't know how many items will be in the array it is possible to REDIM the array as it grows or shrinks. Quote
Heiko Posted February 20, 2004 Posted February 20, 2004 ReDim Preserve, if you want to keep the previous contents (and if it's one-dimensional). Quote .nerd
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.