find a control
Posted
#1
(In Topic #1122)
Regular

Code
Dim hCtrl As Control
For Each hCtrl In Me.Controls
If hCtrl.Name = Last.Name Then
do things!
Endif
Next
Having set the frame's .Name to a unique value.
Is there a better way to do this?
Posted
Regular

Posted
Regular

Code
Public Sub Form_Open()
Dim hFrame As Frame
Dim i As Integer
For i = 0 To 4
With hFrame = New Frame(Me)
.Name = "A" & i
.X = (i * 60)
.Y = 50
.W = 50
.H = 50
.Text = "B" & i
End With
Next
End
How best can I find the .text value of one of the frames?
At the moment I'm using:-
Code
Dim hCtrl As Control
For Each hCtrl In Me.Controls
If hCtrl.Name = "A2" Then
Print hCtrl.Text
Endif
Next
Posted
Regular

Code
Public Sub Button1_Click()
Dim hCtrl As Control
Dim hFrm As Frame
For Each hCtrl In Me.Controls
If hCtrl.Name = "A2" Then
hFrm = hCtrl
Print hFrm.Text
Endif
Next
End
Posted
Regular

Posted
Regular

But, if you know the name of the control, e.g. "A2" then doesn't Me.A2 work?
or maybe Me.Controls["A2"]
I'm just poking about here.
b
Posted
Regular

Dim hFrm As Frame
hFrm = Me.Controls["A3"]
Print hFrm.Text
Thanks for your advice.
Posted
Regular

Actually, my code is more functional if you have Controls of various types on the Form that do not need to be searched based on one of their Properties.bill-lancaster said
Thanks Vuott, this works…
If, on the other hand, you need to know the text, owned by the ".Text" Property of a specific Control, to which a value has also been assigned to the ".Name" Property, I think thatbruce's suggestion is better.
Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Guru

Posted
Regular

Europaeus sum !
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
<COLOR color="#FF8000">Amare memorentes atque deflentes ad mortem silenter labimur.</COLOR>
Posted
Expert

It is called after the record is updated, resetting the input fields so new data can be entered. Aspects of the code may be useful if you want to do more than a simple search.
It is designed to work by passing a parent container such as a panel or frame, rather than a Form…
As I utilise single form maintenance rather than one form for displaying & selecting the records and another to do the maintenance so the controls to enter/update data exist on a panel/frame which I set visibility as required.
Code (gambas)
- TPanel = ControlElement
- FormResetControls(TPanel[TmpInt]) 'It may have children so do a recursive search
- TStrip = ControlElement
- FormResetControls(TStrip[TmpInt]) 'It may have children so do a recursive search
Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Regular

Regards
1 guest and 0 members have just viewed this.

