S
Sugan
Hi all,
I'm using Visual Basic 2005. I would like to loop through the controls
and wite or get some properties based on the controls.
This is the following piece of code in Visual Basic 6.0
For Each ctl In frm.Controls
sCtlType = TypeName(ctl)
If sCtlType = "Label" Then
ctl.Caption = objLocalizer.GetResourceString(CInt(ctl.Tag))
ElseIf sCtlType = "CommandButton" Then
nVal = 0
nVal = Val(ctl.Tag)
ElseIf sCtlType = "Menu" Then
ctl.Caption =
objLocalizer.GetResourceString(CInt(ctl.Caption))
ElseIf sCtlType = "TabStrip" Then
For Each obj In ctl.Tabs
obj.Caption =
objLocalizer.GetResourceString(CInt(obj.Tag))
obj.ToolTipText =
objLocalizer.GetResourceString(CInt(obj.ToolTipText))
Next
ElseIf sCtlType = "Toolbar" Then
For Each obj In ctl.Buttons
obj.ToolTipText =
objLocalizer.GetResourceString(CInt(obj.ToolTipText))
Next
ElseIf sCtlType = "ListView" Then
For Each obj In ctl.ColumnHeaders
obj.Text =
objLocalizer.GetResourceString(CInt(obj.Tag))
Next
ElseIf sCtlType = "ctList" Then
ctl.HeaderFont = fnt
Count = ctl.ColumnCount
For Index = 1 To Count
ctl.ColumnText(Index) =
objLocalizer.GetResourceString(CInt(ctl.ColumnText(Index)))
Debug.Print ctl.ColumnText(Index)
Next Index
ElseIf sCtlType = "SSTab" Then
For Index = 0 To ctl.Tabs
ctl.TabCaption(Index) =
objLocalizer.GetResourceString(CInt(ctl.TabCaption(Index)))
Next Index
ElseIf sCtlType = "ActiveBar" Then
Dim i As Integer
Dim J As Integer
Dim BandCount As Integer
Dim ToolsCount As Integer
BandCount = ctl.Bands.Count
For i = 0 To BandCount
ToolsCount = ctl.Bands(Index).Tools.Count
For J = 0 To ToolsCount
nVal = 0
nVal = Val(ctl.Bands(i).Tools(J).Tag)
If nVal > 0 Then
ctl.Bands(i).Tools(J).Caption =
objLocalizer.GetResourceString(nVal)
End If
nVal = 0
nVal = Val(ctl.Bands(i).Tools(J).ToolTipText)
If nVal > 0 Then
ctl.Bands(i).Tools(J).ToolTipText =
objLocalizer.GetResourceString(nVal)
End If
Next J
Next i
Else
nVal = 0
nVal = Val(ctl.Tag)
If nVal > 0 Then ctl.Caption =
objLocalizer.GetResourceString(nVal)
nVal = 0
nVal = Val(ctl.ToolTipText)
If nVal > 0 Then ctl.ToolTipText =
objLocalizer.GetResourceString(nVal)
End If
Next
When the same code is to be converted to Visual Basic 2005, i would
like to know how to access
1. ctl.HeaderFont in case of "ctList"
2. ctl.ColumnCount in case of "ctList"
3. ctl.ColumnText(Index) in case of "ctList"
4. ctl.Tabs in case of ctl is a SSTab
5. ctl.TabCaption(Index) in case of a Tab in SSTab
Any Help in this regard would be appreciated
Thanks in advance,
Sugan
I'm using Visual Basic 2005. I would like to loop through the controls
and wite or get some properties based on the controls.
This is the following piece of code in Visual Basic 6.0
For Each ctl In frm.Controls
sCtlType = TypeName(ctl)
If sCtlType = "Label" Then
ctl.Caption = objLocalizer.GetResourceString(CInt(ctl.Tag))
ElseIf sCtlType = "CommandButton" Then
nVal = 0
nVal = Val(ctl.Tag)
ElseIf sCtlType = "Menu" Then
ctl.Caption =
objLocalizer.GetResourceString(CInt(ctl.Caption))
ElseIf sCtlType = "TabStrip" Then
For Each obj In ctl.Tabs
obj.Caption =
objLocalizer.GetResourceString(CInt(obj.Tag))
obj.ToolTipText =
objLocalizer.GetResourceString(CInt(obj.ToolTipText))
Next
ElseIf sCtlType = "Toolbar" Then
For Each obj In ctl.Buttons
obj.ToolTipText =
objLocalizer.GetResourceString(CInt(obj.ToolTipText))
Next
ElseIf sCtlType = "ListView" Then
For Each obj In ctl.ColumnHeaders
obj.Text =
objLocalizer.GetResourceString(CInt(obj.Tag))
Next
ElseIf sCtlType = "ctList" Then
ctl.HeaderFont = fnt
Count = ctl.ColumnCount
For Index = 1 To Count
ctl.ColumnText(Index) =
objLocalizer.GetResourceString(CInt(ctl.ColumnText(Index)))
Debug.Print ctl.ColumnText(Index)
Next Index
ElseIf sCtlType = "SSTab" Then
For Index = 0 To ctl.Tabs
ctl.TabCaption(Index) =
objLocalizer.GetResourceString(CInt(ctl.TabCaption(Index)))
Next Index
ElseIf sCtlType = "ActiveBar" Then
Dim i As Integer
Dim J As Integer
Dim BandCount As Integer
Dim ToolsCount As Integer
BandCount = ctl.Bands.Count
For i = 0 To BandCount
ToolsCount = ctl.Bands(Index).Tools.Count
For J = 0 To ToolsCount
nVal = 0
nVal = Val(ctl.Bands(i).Tools(J).Tag)
If nVal > 0 Then
ctl.Bands(i).Tools(J).Caption =
objLocalizer.GetResourceString(nVal)
End If
nVal = 0
nVal = Val(ctl.Bands(i).Tools(J).ToolTipText)
If nVal > 0 Then
ctl.Bands(i).Tools(J).ToolTipText =
objLocalizer.GetResourceString(nVal)
End If
Next J
Next i
Else
nVal = 0
nVal = Val(ctl.Tag)
If nVal > 0 Then ctl.Caption =
objLocalizer.GetResourceString(nVal)
nVal = 0
nVal = Val(ctl.ToolTipText)
If nVal > 0 Then ctl.ToolTipText =
objLocalizer.GetResourceString(nVal)
End If
Next
When the same code is to be converted to Visual Basic 2005, i would
like to know how to access
1. ctl.HeaderFont in case of "ctList"
2. ctl.ColumnCount in case of "ctList"
3. ctl.ColumnText(Index) in case of "ctList"
4. ctl.Tabs in case of ctl is a SSTab
5. ctl.TabCaption(Index) in case of a Tab in SSTab
Any Help in this regard would be appreciated
Thanks in advance,
Sugan