To save time, and not recreate my 21 userform, i have imported in vb6 classic a userform of Excel.
In the internal of this userform i have a frame1 with 34 Lable.
i loop, in my old excel project with this:
Sub RESET_CAPTION()
Dim CTL As Control
For Each CTL In Frame1.Controls
TEST = CTL.Name
If Left(TEST, 1) = "B" Then
CTL.ForeColor = &H0&
End If
Next CTL
End Sub
no prob....
But in VB6 the code go in error in: For Each CTL In Frame1.Controls. error 13 type mismach
HELP ME!!!!
ref:http://www.eileenslounge.com/viewtopic. ... As+Control
VB6 and excel useform
-
- Administrator
- Posts: 78512
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: VB6 and excel useform
In VB6, a frame control does not have a Controls collection. You can use the following instead:
Code: Select all
Sub RESET_CAPTION()
Dim CTL As Control
For Each CTL In Me.Controls
If CTL.Container Is Frame1 Then
TEST = CTL.Name
If Left(TEST, 1) = "B" Then
CTL.ForeColor = &H0&
End If
End If
Next CTL
End Sub
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4357
- Joined: 26 Apr 2010, 17:36
Re: VB6 and excel useform
SAME ERROR in: For Each CTL In Me.Controls. error 13 type mismachHansV wrote:In VB6, a frame control does not have a Controls collection. You can use the following instead:
Code: Select all
Sub RESET_CAPTION() Dim CTL As Control For Each CTL In Me.Controls If CTL.Container Is Frame1 Then TEST = CTL.Name If Left(TEST, 1) = "B" Then CTL.ForeColor = &H0& End If End If Next CTL End Sub
-
- Administrator
- Posts: 78512
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: VB6 and excel useform
What happens if you remove the line
and then type it again (don't copy / paste)?
If that doesn't help, what if you change the above line to
Code: Select all
Dim CTL As Control
If that doesn't help, what if you change the above line to
Code: Select all
Dim CTL As Object
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4357
- Joined: 26 Apr 2010, 17:36
Re: VB6 and excel useform
HansV wrote:What happens if you remove the line
and then type it again (don't copy / paste)?Code: Select all
Dim CTL As Control
If that doesn't help, what if you change the above line to
Code: Select all
Dim CTL As Object
You are The Champion...
Great Hans, only you!!!!
With ... As Object work a charm.
Tks.