-
May 8th, 2021, 04:09 AM
#1
Thread Starter
PowerPoster
EXCLUDE control from a looping
Code:
Private Sub PULISCI_TUTTO_ESCLUSO()
Dim CTL As Control, TIPO As String
For Each CTL In Me.Controls
If TypeOf CTL Is ComboBox Then
TIPO = CTL.Name
If TIPO <> "CDARRIVO" Or TIPO <> "CTIPALLOGGIATO" Then
Debug.Print CTL.Name
CTL.Text = ""
End If
End If
Next CTL
End Sub
why the <> dont work!
in debug.print have CDARRIVO!!!! or CTIPALLOGGIATO!!!!
-
May 8th, 2021, 04:52 AM
#2
Re: EXCLUDE control from a looping
Originally Posted by luca90
Code:
Private Sub PULISCI_TUTTO_ESCLUSO()
Dim CTL As Control, TIPO As String
For Each CTL In Me.Controls
If TypeOf CTL Is ComboBox Then
TIPO = CTL.Name
If TIPO <> "CDARRIVO" Or TIPO <> "CTIPALLOGGIATO" Then
Debug.Print CTL.Name
CTL.Text = ""
End If
End If
Next CTL
End Sub
why the <> dont work!
in debug.print have CDARRIVO!!!! or CTIPALLOGGIATO!!!!
Reconsider the conditions ... at least one of them applies to every control.
Try with And instead of Or.
Wolfgang
-
May 8th, 2021, 04:55 AM
#3
Thread Starter
PowerPoster
Re: EXCLUDE control from a looping
Originally Posted by Wolfgang Enzinger
Reconsider the conditions ... at least one of them applies to every control.
Try with And instead of Or.
Wolfgang
NOT understAND...can you modify, my code.Tks
-
May 8th, 2021, 04:56 AM
#4
Re: EXCLUDE control from a looping
Replace the "Or" operator with "And". I will try to explain what is happening, in your test "CDARRIVO" may be matched while "CTIPALLOGGIATO" is not. Or the other way around. This results in the following situation:
True Or False = True
False Or True = True
When using the Or operator you're asking for both controls not to be found in a single loop instead of either one or the other.
True And False = False
False And True = False
Last edited by Peter Swinkels; May 8th, 2021 at 05:19 AM.
Reason: typo
-
May 8th, 2021, 05:10 AM
#5
Re: EXCLUDE control from a looping
Code:
If TIPO <> "CDARRIVO" And TIPO <> "CTIPALLOGGIATO" Then
-
May 8th, 2021, 09:43 AM
#6
Re: EXCLUDE control from a looping
Or you could also write it like
Code:
If Not (TIPO = "CDARRIVO" Or TIPO = "CTIPALLOGGIATO") Then
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|