
'============================
'===== Routine UserForm =====
'============================
Private Sub mPulisciTextBox()
Dim ctrl As Control
With Me.frInserimentoDati
'With Me.frRagioneSociale 'Mi da errore. Avrei bisogno di pulire anche queste TXTbox.Come posso correggerlo?
' cosa devo aggiungere?
'With Me.frReferente
For Each ctrl In .Controls
If TypeOf ctrl Is _
MSForms.TextBox Then
ctrl.Text = ""
End If
Next
End With
Set ctrl = Nothing
End Sub |
Dim ctrl As Control
With Me
For Each ctrl In .Controls
If TypeOf ctrl Is MSForms.TextBox Then
ctrl.Text = "A"
End If
Next
End With |
Dim oCtrl As Control
For Each oCtrl In Me.Controls
If TypeName(oCtrl) = "TextBox" Then
oCtrl.Text = ""
End If
Next |
'==================================
'===== Pulsanti frame Ricerca =====
'==================================
Private Sub cmdPrimo_Click()
Call Alimenta_Form(2)
lRigaAttiva = 2
Me.cmdInserisci.Enabled = False
End Sub
Private Sub cmdAvanti_Click()
If Not lRigaAttiva >= lUltRiga Then
lRigaAttiva = lRigaAttiva + 1
Call Alimenta_Form(lRigaAttiva)
End If
Me.cmdInserisci.Enabled = False
End Sub
Private Sub cmdIndietro_Click()
If Not lRigaAttiva <= 2 Then
lRigaAttiva = lRigaAttiva - 1
Call Alimenta_Form(lRigaAttiva)
End If
Me.cmdInserisci.Enabled = False
End Sub
Private Sub cmdUltimo_Click()
Call Alimenta_Form(lUltRiga)
lRigaAttiva = lUltRiga
Me.cmdInserisci.Enabled = False
End Sub
Private Sub Alimenta_Form(ByVal Riga As Long)
With Me
.txtID.Text = sh.Range("A" & Riga).Value
.txtNome.Text = sh.Range("B" & Riga).Value
.txtIndirizzo.Text = sh.Range("C" & Riga).Value
.txtCivico.Text = sh.Range("D" & Riga).Value
.txtComune.Text = sh.Range("E" & Riga).Value
.txtProvincia.Text = sh.Range("F" & Riga).Value
.txtTelefono.Text = sh.Range("G" & Riga).Value
.txtCellulare.Text = sh.Range("H" & Riga).Value
.txtEmail.Text = sh.Range("I" & Riga).Value
.txtSito_Internet.Text = sh.Range("J" & Riga).Value
.txtRuolo.Text = sh.Range("K" & Riga).Value
.txtC_F.Text = sh.Range("L" & Riga).Value
.txtReferente_1.Text = sh.Range("M" & Riga).Value
.txtRecapito_1.Text = sh.Range("N" & Riga).Value
.txtReferente_2.Text = sh.Range("O" & Riga).Value
.txtRecapito_2.Text = sh.Range("P" & Riga).Value
.txtReferente_3.Text = sh.Range("Q" & Riga).Value
.txtRecapito_3.Text = sh.Range("R" & Riga).Value
.txtRagione_Sociale.Text = sh.Range("S" & Riga).Value
.txtIndirizzo_2.Text = sh.Range("T" & Riga).Value
End With
End Sub |
DA COSI': With Me.frInserimentoDati For Each ctrl In .Controls next ctrl end with A COSI': With Me For Each ctrl In .Controls next ctrl end with |
Private Sub Alimenta_Form(ByVal Riga As Long)
Dim nStart As Single
Dim j As Long
Dim k As Long
nStart = Timer
For j = 1 To 10000
With Me
.txtID.Text = sh.Range("A" & Riga).Value
.txtNome.Text = sh.Range("B" & Riga).Value
.txtIndirizzo.Text = sh.Range("C" & Riga).Value
.txtCivico.Text = sh.Range("D" & Riga).Value
.txtComune.Text = sh.Range("E" & Riga).Value
.txtProvincia.Text = sh.Range("F" & Riga).Value
.txtTelefono.Text = sh.Range("G" & Riga).Value
.txtCellulare.Text = sh.Range("H" & Riga).Value
.txtEmail.Text = sh.Range("I" & Riga).Value
.txtSito_Internet.Text = sh.Range("J" & Riga).Value
.txtRuolo.Text = sh.Range("K" & Riga).Value
.txtC_F.Text = sh.Range("L" & Riga).Value
.txtReferente_1.Text = sh.Range("M" & Riga).Value
.txtRecapito_1.Text = sh.Range("N" & Riga).Value
.txtReferente_2.Text = sh.Range("O" & Riga).Value
.txtRecapito_2.Text = sh.Range("P" & Riga).Value
.txtReferente_3.Text = sh.Range("Q" & Riga).Value
.txtRecapito_3.Text = sh.Range("R" & Riga).Value
.txtRagione_Sociale.Text = sh.Range("S" & Riga).Value
.txtIndirizzo_2.Text = sh.Range("T" & Riga).Value
End With
Next j
MsgBox Timer - nStart
End Sub
Private Sub Alimenta_Form2(ByVal Riga As Long)
Dim nStart As Single
Dim j As Long
Dim k As Long
nStart = Timer
For j = 1 To 10000
With Me
For k = 1 To 20 'tante sono le textbox riempite sopra
.txtID.Text = sh.Range("A" & Riga).Value
Next k
End With
Next j
MsgBox Timer - nStart
End Sub |
Private Sub Alimenta_Form(ByVal Riga As Long)
Dim col As Integer, v As Variant
col = 0
For Each v In Array(txtID, txtNome, txtIndirizzo, txtCivico, txtComune, txtProvincia, _
txtTelefono, txtCellulare, txtEmail, txtSito_Internet, txtRuolo, txtC_F, txtReferente_1, _
txtRecapito_1, txtReferente_2, txtRecapito_2, txtReferente_3, txtRecapito_3, _
txtRagione_Sociale, txtIndirizzo_2)
col = col + 1
v.Value = sh.Cells(Riga, col)
Next
End Sub
|
