On Thu, 16 Jul 2015, Rolf-Werner Eilert wrote: > Never used a Struct, and now playing around with it I find the help > texts cannot help me. This is what I tried: > > Public Struct Hund > Wau As String > End Struct > > Public Sub Button3_Click() > Dim Wauwau As New Hund > > Wauwau.Wau = "Bone" > > Everything ok, but it's ONE Wauwau only. From the description, I would > expect an array. >
Why would you expect an array? And of what: an array of Struct Hund or an array of Strings inside your one Hund instance? Arrays are only to be expected where the "[]" occur. > So I tried > > Public Struct Hund > Wau As String[] > End Struct > > Public Sub Button3_Click() > Dim Wauwau As New Hund > > Wauwau.Wau.Add("Bone") > > and I get a "Null object" for the Add function. > > What's going wrong here? > What you did, in non-Struct terms, is basically this: Dim myArray As String[] myArray.Add("Bone") You declared a variable which can hold an array of strings, did NOT create the array and tried to add something to it. You should have done Dim myArray As New String[] myArray.Add("Bone") or Dim myArray As String[] myArray = New String[] myArray.Add("Bone") and similarly Dim Wauwau As New Hund Wauwau.Wau = New String[] Wauwau.Wau.Add("Bone") A Struct is just a class without properties, methods and events. It has only public variables. Regards, Tobi -- "There's an old saying: Don't change anything... ever!" -- Mr. Monk ------------------------------------------------------------------------------ Don't Limit Your Business. Reach for the Cloud. GigeNET's Cloud Solutions provide you with the tools and support that you need to offload your IT needs and focus on growing your business. Configured For All Businesses. Start Your Cloud Today. https://www.gigenetcloud.com/ _______________________________________________ Gambas-user mailing list Gambas-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/gambas-user