
Private Sub LstMontanti_AfterUpdate() 'Quando seleziona la riga ListBox carica i dati nel riquadro sottostante
Dim i As Integer 'Definisco la matrice in variabile integer
For i = 0 To LstMontanti.ListCount - 1 'Ciclo For di lunghezza uguale al contenuto della ListBox
If LstMontanti.Selected(i) = True Then 'Se trova una riga selezionata trascrive i valori:
TbxDescrizione.Value = LstMontanti.List(i, 0) 'Trascrive il valore DESCRIZIONE nel riquadro sottostante
TbxPrezzo.Value = LstMontanti.List(i, 1) 'Trascrive il valore PREZZO nel riquadro sottostante
TbxTempo.Value = LstMontanti.List(i, 2) 'Trascrive il valore TEMPO nel riquadro sottostante
TbxFilo.Value = LstMontanti.List(i, 3) 'Trascrive il valore FILO nel riquadro sottostante
TbxTubo.Value = LstMontanti.List(i, 4) 'Trascrive il valore TUBO nel riquadro sottostante
TbxCap.Value = LstMontanti.List(i, 5) 'Trascrive il valore CAPITOLATO nel riquadro sottostante
End If
Next i
End Sub
Private Sub LstVarie_AfterUpdate() 'Quando seleziona la riga ListBox carica i dati nel riquadro sottostante
Dim i As Integer 'Definisco la matrice in variabile integer
For i = 0 To LstVarie.ListCount - 1 'Ciclo For di lunghezza uguale al contenuto della ListBox
If LstVarie.Selected(i) = True Then 'Se trova una riga selezionata trascrive i valori:
TbxDescrizione.Value = LstVarie.List(i, 0) 'Trascrive il valore DESCRIZIONE nel riquadro sottostante
TbxPrezzo.Value = LstVarie.List(i, 1) 'Trascrive il valore PREZZO nel riquadro sottostante
TbxTempo.Value = LstVarie.List(i, 2) 'Trascrive il valore TEMPO nel riquadro sottostante
TbxFilo.Value = LstVarie.List(i, 3) 'Trascrive il valore FILO nel riquadro sottostante
TbxTubo.Value = LstVarie.List(i, 4) 'Trascrive il valore TUBO nel riquadro sottostante
TbxCap.Value = LstVarie.List(i, 5) 'Trascrive il valore CAPITOLATO nel riquadro sottostante
End If
Next i
End Sub |
For Each ctl In UserForm1.Controls
If TypeName(ctl) = ”ListBox” Then
TbxDescrizione.Value = ctl.List(i, 0)
......
......
End If
Next
|
'nell'userform
Private Sub LstMontanti_AfterUpdate() 'Quando seleziona la riga ListBox carica i dati nel riquadro sottostante
call fai_qualcosa(lstmontanti)
end sub
private sub Private Sub LstVarie_AfterUpdate()
call fai_qualcosa(lstmontanti)
end sub
'eccetera con tutti gli altri millemila eventi afterupdate
'-----------------------------------------------------
'in un modulo
sub fai_qualcosa(ctl)
Dim i As Integer 'Definisco la matrice in variabile integer
with ctl
For i = 0 To .ListCount - 1 'Ciclo For di lunghezza uguale al contenuto della ListBox
If .Selected(i) = True Then 'Se trova una riga selezionata trascrive i valori:
TbxDescrizione.Value = .List(i, 0) 'Trascrive il valore DESCRIZIONE nel riquadro sottostante
TbxPrezzo.Value = .List(i, 1) 'Trascrive il valore PREZZO nel riquadro sottostante
TbxTempo.Value = .List(i, 2) 'Trascrive il valore TEMPO nel riquadro sottostante
TbxFilo.Value = .List(i, 3) 'Trascrive il valore FILO nel riquadro sottostante
TbxTubo.Value = .List(i, 4) 'Trascrive il valore TUBO nel riquadro sottostante
TbxCap.Value = .List(i, 5) 'Trascrive il valore CAPITOLATO nel riquadro sottostante
End If
Next i
end with
end if |
il secondo afterupdate è ovviamente questo, ma il concetto l'hai capito.
private sub Private Sub LstVarie_AfterUpdate()
call fai_qualcosa(lstVarie)
end sub |
