G
Galen Somerville
Just looking for thoughts on converting VB6 Control arrays.
Here's the way I did it. The control happens to be a Usercontrol, CircVol,
but could be any control.
I would appreciate any suggestions on a better way to do it.
GalenS
DECLARATION
Public UserSwp As ArrayList
FORM_LOAD
BuildUserSwp()
BUILD
Private Sub BuildUserSwp()
UserSwp = New ArrayList
UserSwp.Add(CircVol1)
UserSwp.Add(CircVol2)
UserSwp.Add(CircVol3)
UserSwp.Add(CircVol4)
UserSwp.Add(CircVol5)
UserSwp.Add(CircVol6)
End Sub
BUTTON_CLICK
Private Sub UserSwpAll_Click(ByVal sender As Object, ByVal e As
System.EventArgs) _
Handles CircVol1.Click, CircVol2.Click, CircVol3.Click, CircVol4.Click,
_
CircVol5.Click, CircVol6.Click
Dim Index As Integer
Select Case sender.name
Case "CircVol1"
Index = 0
Case "CircVol2"
Index = 1
Case "CircVol3"
Index = 2
Case "CircVol4"
Index = 3
Case "CircVol5"
Index = 4
Case "CircVol6"
Index = 5
End Select
gCtrls.ChnVol(Index) = CByte(UserSwp(Index).volval)
Call UpdatePots(Index, gCtrls.ChnVol(Index))
End Sub
PARTIAL USAGE
For Index = 0 To 4
UserSwp(Index).circName = Chr(Inner)
UserSwp(Index).Width = 90
UserSwp(Index).Height = 97
UserSwp(Index).circBackColor = Me.BackColor
Call SetControl(Index, gCtrls.ChnVol(Index))
LabControl(Index).Text = Chr(Inner)
Inner = Inner + 1
Next
UserSwp(5).Name = "LUNG"
UserSwp(5).circBackColor = Me.BackColor
ANOTHER USAGE
For Index = 1 To 6
gCtrls.ChnVol(Index - 1) = gbytEPA(Index)
frmSweep.UserSwp(Index - 1).VolVal = gbytEPA(Index)
Next Index
Here's the way I did it. The control happens to be a Usercontrol, CircVol,
but could be any control.
I would appreciate any suggestions on a better way to do it.
GalenS
DECLARATION
Public UserSwp As ArrayList
FORM_LOAD
BuildUserSwp()
BUILD
Private Sub BuildUserSwp()
UserSwp = New ArrayList
UserSwp.Add(CircVol1)
UserSwp.Add(CircVol2)
UserSwp.Add(CircVol3)
UserSwp.Add(CircVol4)
UserSwp.Add(CircVol5)
UserSwp.Add(CircVol6)
End Sub
BUTTON_CLICK
Private Sub UserSwpAll_Click(ByVal sender As Object, ByVal e As
System.EventArgs) _
Handles CircVol1.Click, CircVol2.Click, CircVol3.Click, CircVol4.Click,
_
CircVol5.Click, CircVol6.Click
Dim Index As Integer
Select Case sender.name
Case "CircVol1"
Index = 0
Case "CircVol2"
Index = 1
Case "CircVol3"
Index = 2
Case "CircVol4"
Index = 3
Case "CircVol5"
Index = 4
Case "CircVol6"
Index = 5
End Select
gCtrls.ChnVol(Index) = CByte(UserSwp(Index).volval)
Call UpdatePots(Index, gCtrls.ChnVol(Index))
End Sub
PARTIAL USAGE
For Index = 0 To 4
UserSwp(Index).circName = Chr(Inner)
UserSwp(Index).Width = 90
UserSwp(Index).Height = 97
UserSwp(Index).circBackColor = Me.BackColor
Call SetControl(Index, gCtrls.ChnVol(Index))
LabControl(Index).Text = Chr(Inner)
Inner = Inner + 1
Next
UserSwp(5).Name = "LUNG"
UserSwp(5).circBackColor = Me.BackColor
ANOTHER USAGE
For Index = 1 To 6
gCtrls.ChnVol(Index - 1) = gbytEPA(Index)
frmSweep.UserSwp(Index - 1).VolVal = gbytEPA(Index)
Next Index