Ecco invece come l'uso delle strutture può risolvere egregiamente il problema, anzi è l'unica soluzione possibile.
Si istanzia diverse volte, con diversi valori, la struttura avente per membri le varie proprietà delle labels, e quindi si passa alla routine come parametro una diversa istanza della struttura a seconda della "combinazione" di proprietà da dare alla label.
Public Class Form1
Structure Struttura
Dim colore As Color
Dim altezza As Integer
End Structure
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim lblStruc As Struttura
lblStruc.altezza = 500
lblStruc.colore = Color.Cyan
Dim lblstruc2 As Struttura
With lblstruc2
.altezza = 300
.colore = Color.Red
End With
routine(Label1, lblStruc)
routine(Label2, lblstruc2)
End Sub
Sub routine(ByRef casella As Label, ByVal strut As Struttura)
With casella
.BackColor = strut.colore
.Height = strut.altezza
End With
End Sub
End Class
E funziona egregiamente!!!
Nessun commento:
Posta un commento