Code: Select all
Dim hCtrl As Control
For Each hCtrl In Me.Controls
If hCtrl.Name = Last.Name Then
do things!
Endif
Next
Is there a better way to do this?
Code: Select all
Dim hCtrl As Control
For Each hCtrl In Me.Controls
If hCtrl.Name = Last.Name Then
do things!
Endif
Next
Dim hCtl as Object
hCtl = Last
DoThings
Code: Select all
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
Code: Select all
Dim hCtrl As Control
For Each hCtrl In Me.Controls
If hCtrl.Name = "A2" Then
Print hCtrl.Text
Endif
Next
Code: Select all
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
Public Sub Button1_Click()
Dim ob as Object
For Each ob In Me.Controls
If ob.Name = "A2" Then Print ob.Text
Next
End
Thanks for your advice.Dim hFrm As Frame
hFrm = Me.Controls["A3"]
Print hFrm.Text
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.
Dim hFrm As Frame = Me["A3"]
Print hFrm.Text
Private ffrr As New Frame[5]
Public Sub Form_Open()
For b As Byte = 0 To 4
With ffrr[b] = New Frame(Me)
.Name = "A" & b
.X = (b * 60)
.Y = 50
.W = 50
.H = 50
.Text = "B" & b
End With
Next
End
Public Sub Button1_Click()
Print ffrr[2].Text
End