[Gambas-user] VB to Gambas

Eilert eilert-sprachen at ...221...
Thu Mar 3 17:37:41 CET 2005


No, I still don't get it running this way. :-)

This time I included it like here. This is intended to give default 
values for a table. There is a class named "tab" with the variables and 
an Object[] named tb. Then within Form_Activate I do this:

DIM tabelle AS NEW tab

'[blabla]
'a lot of single values that may stay for all columns
'so just an example:
	
	tabelle.SpalteBreite = 30

	FOR i = 0 to 4
		tabelle.KopfText = "Kopf" & Cstr(i)
		tb.Add(tabelle)
	next i

So in my opinion, it should store the same values for SpalteBreite, but 
different strings for KopfText. Now, when I want to read the values for 
a certain column, I always get the same; the same value as for the last 
item:

PUBLIC SUB Spaltennr_Change()

	txtKopf.Text = tb[Spaltennr.Value].KopfText

END

always gives me "Kopf 4". I've tested tabelle.KopfText within the 
FOR-NEXT loop, that one is ok. Giving a fixed value like tb[2].KopfText 
also returns "Kopf 4".

What do I do wrong here?

Thxs for your help!

Rolf





Ron Onstenk schrieb:
> On Thursday 03 March 2005 10:02, Eilert wrote:
> 
>>Hi Charlie,
>>
>>is it possible to use this with array objects? I've been trying around a
>>bit here, but no hope.
>>
>>Two questions:
>>First: when I try STATIC PUBLIC like in your example, I get an error
>>message "ProgType is static" when trying to stuff something into the
>>variable. So I changed it to a simple "PUBLIC", then it was ok. Why's that?
>>
>>Well, now this:
>>
>>This is an example of what I tryed based on your example:
>>
>>
>>' Gambas class file ProgType
>>
>>PUBLIC Name AS String[]
>>PUBLIC Pfad AS String[]
>>PUBLIC Verzeichnis AS String[]
>>
>>'This is in another class (form)
>>
>>PUBLIC Prog1 AS NEW ProgType
>>
>>or
>>
>>STATIC Prog1 AS NEW ProgType
>>
>>
>>and in a SUB there:
>>
>>	Prog1.Pfad.Add("hello")
>>
>>The automatic list appears, so Gambas understands this is an array
>>object, it offers "Name", "Pfad", .Add etc., everything ok so far, but
>>when I run it I get this "Null object" error.
>>
>>Why?
>>
>>I tried to declare the array at different places and in different ways,
>>but there is always the same error.
>>
>>Rolf
>>
> 
> 
> ----------------------
> ' Gambas class file ProgType
> PUBLIC Name AS String
> PUBLIC Pfad AS String
> PUBLIC Verzeichnis AS String
> --------------------
> 
> 'This is in another class (form)
> PUBLIC Prog1 AS NEW object[] ' objects of ProgType
>  or
> STATIC PUBLIC Prog1 AS NEW object[] ' objects of ProgType
> 
> I belive STATIC should be the correct one, try and error ;)
> 
> and in a SUB there:
> PUBLIC SUB onButton1Click()
> 
> 	DIM progdata AS NEW ProgType
> 	progdata.Name= "the_name"
> 	progdata.Pfad = "The_Pfad"
> 	progdata.Verzeichnis = "The_Ordner"
> 
> 
>>	Prog1.Pfad.Add("hello")
> 
> 	Prog1.Add(progdata) 'Prog1 is the array of progdata's
> END
> 
> May be this will help as a guide.
> 
> Ron
> 
> 
> -------------------------------------------------------
> SF email is sponsored by - The IT Product Guide
> Read honest & candid reviews on hundreds of IT Products from real users.
> Discover which products truly live up to the hype. Start reading now.
> http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 





More information about the User mailing list