You are not logged in.

IOSIMURA

Beginner

  • "IOSIMURA" is male
  • "IOSIMURA" started this thread

Posts: 1

Date of registration: Jan 12th 2011

Location: Brasil

Occupation: Analista de sistemas

Hobbies: Coder

  • Send private message

1

Sunday, January 16th 2011, 6:49am

Error in expression "For Each TempObj In Forms" (FORMS ?? Why)

Somebody can help me please ?
How can i convert this function to work in JABACO ?

-----------------------------------------------------------------------------------------------------------

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Option Explicit

Private Sub Command1_Click()

 Dim FrmObj As Form, TempObj As Form
 Dim StrVal As String
 Dim Find As Boolean
 
 Find = False
 StrVal = "Form2"
 
 For Each TempObj In Forms
 
 If TempObj.Name = StrVal Then
 
 Set FrmObj = TempObj
 Find = True
 
 End If
 
 Next
 
 If Find = True Then FrmObj.Show
 

End Sub



Private Sub Form_Load()

 Load Form2

End Sub



--------------------------------------------------------------------------------------------------------
tk's

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

2

Sunday, January 16th 2011, 10:34am

Jabaco by default has no collection of Forms.
It has no collection of Controls either.

If you want to enumerate Forms or Controls you have to define the collection yourself
and add all collection items during initialization.

Example for Controls:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
'  keep all user controls in a list
Private ucList As java#util#ArrayList

Public Sub Form_Load()
   myForm1 = Me                      '  cf. mdlGlobal variable
   ucList = New java#util#ArrayList  '  list of user controls   
End Sub

Public Sub cmdReset_Click()
   Dim i As Integer 
   
   For i = 0 To ucList.size - 1
      '  all our usercontrols implement interface IUCreset
      Cast(ucList.get(i), IUCreset).reset 
   Next i
End Sub

'  called out of the usercontrol initialization
Public Sub registerUsercontrol(uc As IUCreset)
   ucList.add uc
End Sub


Source snippet of a usercontrol:

Jabaco Source

1
2
3
4
5
6
7
8
9
10
11
12
Implements IUCreset

Private initCalls As Integer 

Public Sub Init()

   initCalls = initCalls + 1
   
   If initCalls = 1 Then
      myForm1.registerUsercontrol Me 
   End If 
End Sub


Greetings

A1880

scGuy

Beginner

Posts: 40

Date of registration: Jan 12th 2011

  • Send private message

3

Monday, January 17th 2011, 5:22pm

For fun I started implementing a quick solution for finding a form by name and giving it focus. I noticed this potential oversite in Jabaco:



When you create a form, you can give it a name in the form properties. However in code, the "name" property is not available as expected. So including something like "If MyForm.Name = something then" does not compile. I will also post this issue in the "bugs" section.

Rate this thread
WoltLab Burning Board