You are not logged in.

amitmarkel

Beginner

  • "amitmarkel" is male
  • "amitmarkel" started this thread

Posts: 17

Date of registration: Jul 17th 2009

  • Send private message

1

Monday, July 20th 2009, 10:17am

Control arrays LBound

Hi community, Manuel,

I've tried to LBound and UBound control arrays. Whereas UBound works, I think there is a bug with LBound.
I've created a PictureBox array of Picbx(1) and Picbx(2) for example, and other controls such as labels. LBound seems to always result with a zero.

I tried to do it in this fashion:

Jabaco Source

1
Msgbox LBound(Picbx) & UBound(Picbx)


The result is 02, where in VB6 the result is 12.

Regards
Amit

This post has been edited 1 times, last edit by "amitmarkel" (Jul 20th 2009, 10:23am)


OlimilO

Intermediate

  • "OlimilO" is male

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

2

Monday, July 20th 2009, 11:57am

Load & Iterating

Hi Amit,
before you dig more deeper:
Also loading new controls into controlarrays with the Load-procedure is not possible until now.
There is plenty of work left for Manuel ;)
For compiler related stuff the only help we can serve is posting problems together with solutions

The LBound and UBound-functions normally will be used for iterating through the array.

But since we have For Each you could do it like this:
VB6-Code:

Jabaco Source

1
2
3
4
5
6
Dim pic As PictureBox   
   For Each pic In Picture1
      If Not pic Is Nothing Then
         pic.BackColor = vbWhite
      End If
   Next


Jabaco-Code:

Jabaco Source

1
2
3
4
5
6
Dim pic As PictureBox   
   For Each pic In Picture1
      If pic <> Nothing Then
         pic.BackColor = vbWhite
      End If
   Next




OlimilO

amitmarkel

Beginner

  • "amitmarkel" is male
  • "amitmarkel" started this thread

Posts: 17

Date of registration: Jul 17th 2009

  • Send private message

3

Monday, July 20th 2009, 4:11pm

Yeah I know: I just thought that solution could be a little "less elegant" if a LBound function already existed. Thanks however. Next times I'll include any bypassing solutions :), I thought it just might have been a simple bug.

I am sharing my thoughts in goal to help improve Jabaco because in the future it will be powerful, and I wish to aid in bringing that closer. I yet learnt Jabaco and the framework Fully to help with solutions (regarding bugs or suggestions) or assisting in writing documentation, therefore in the meantime I posted bugs I've encountered.

Also -- The forum will be a great foundation of a "MSDN" base!

Amit

This post has been edited 2 times, last edit by "amitmarkel" (Jul 20th 2009, 7:12pm)


A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

4

Monday, July 20th 2009, 7:39pm

Hi,
looking through the de-compiled code of an array-of-controls sample, I've found that LBound() is actually correct returning 0.
The error is that the array is always created with LBound() 0 in the first place regardless of the index figures declared in the form.
So, an easy workaround is to actually use a zero-based index interval 0..n
If you do insist on a non-zero limit, you can use something like "Redim Preserve Command1(11 To 12)" in your Form1.Load() routine.

For Manuel's to-fix list: the array bounds should be set correctly right after array creation. A "SetBound()" is missing in the generated code.

Cheers!

A1880

Manuel

Administrator

  • "Manuel" is male

Posts: 256

Date of registration: Jul 16th 2008

Location: Erlangen, Germany

Occupation: Software Developer

Hobbies: Jabaco, game theory, text-mining

  • Send private message

5

Monday, July 20th 2009, 8:44pm

Quoted

looking through the de-compiled code of an array-of-controls sample, I've found that LBound() is actually correct returning 0. The error is that the array is always created with LBound() 0
Thank you for debugging. I'll fix that.

Rate this thread
WoltLab Burning Board