[Gambas-user] Questions about function

wspinto at ...1405... wspinto at ...1405...
Thu Sep 28 18:54:13 CEST 2006


Hi!

In VB the functions and Sub use MYSUBFUNCTION([ByRef | ByVal] myVariable as
typeofvariable) as typeofreturn

Example:
SUB MYSub1(b as integer)
    b = b ^ 2
END SUB

SUB MYSub2(ByRef b as integer)
    b = b ^ 2
END SUB

a = 10
PRINT a <== Return 10
MYSub1(a)
PRINT a <== Return 10
MySub2(a)
PRINT a <== Return 100

Well! My problem...

I'm have one variable named oTabIndex is Object[] and fill with this function

PUBLIC FUNCTION MakeTabIndex(oForm AS Form) AS Object[]
  DIM sClass AS Object
  DIM cRetorno AS NEW Object[]

  FOR EACH sClass IN oForm.Controls
    IF sClass Is TEXTBOX or sClass Is COMBOBOX or sClass Is CHECKBOX or sClass
Is LISTBOX
        THEN  cRetorno.Add(sClass)
  NEXT

  RETURN cRetorno
END

PUBLIC SUB Form_Open()
    oTabIndex = mymodule.MakeTabIndex(ME)
END

PUBLIC SUB loc_KeyPress()    '* loc is group of my form objects
    If Key.Code = Key.Enter or Key.Code = Key.Return then
        FtabIndex(oTabIndex,LAST,0)
    End If
END

FUNCTION FTabIndex(oTabIndex AS Object[], oCampo AS Object, OPTIONAL nOrdem AS
Integer = 0) AS Boolean
    DIM nConta AS Integer
    DIM i AS Integer

    i = oTabIndex.Count - 1
    nConta = oTabIndex.Find(oCampo)
    IF nConta < 0 THEN RETURN FALSE

    IF nOrdem = 0 THEN
        ' Verifica se o campo esta enable ou nao visible
        nConta += 1
        IF nConta = i THEN nConta = 0
        WHILE NOT oTabIndex[nConta].enabled OR NOT oTabIndex[nConta].visible
            nConta += 1
            IF nConta = i THEN nConta = 0
        WEND
    ELSE
        nConta -= 1
        IF nConta <= 0 THEN nConta = i
        WHILE NOT oTabIndex[nConta].enabled OR NOT oTabIndex[nConta].visible
            nConta -= 1
            IF nConta <= 0 THEN nConta = i
        WEND
    ENDIF

    oTabIndex[nConta].SetFocus
    RETURN TRUE
END

**************
In any moment the oTabIndex itens not exist
example:
For i = 0 to oTabIndex.Count - 1
    Print oTabIndex[i].Tag
Next

first time the work fine. In second time in i = 5 the oTabIndex[5].Tag is
invalid or any other: .Text, .X, etc...

Why?????????


Reguards,

     Wellington
___________________________________________________________________________________
Agora todas as suas ligações DDD e DDI com o 21 vêm junto com a conta do seu
telefone de casa ou celular. 
Mais comodidade e praticidade para você. Faz um 21 e aproveite!





More information about the User mailing list