Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
Confronta due variabili di riferimento a oggetti.
Sintassi
result = object1 Is object2
Parti
result
Obbligatorio. Qualsiasi Boolean
valore.
object1
Obbligatorio. Qualsiasi Object
nome.
object2
Obbligatorio. Qualsiasi Object
nome.
Osservazioni:
L'operatore Is
determina se due riferimenti a oggetti fanno riferimento allo stesso oggetto. Tuttavia, non esegue confronti di valori. Se object1
e object2
entrambi fanno riferimento alla stessa istanza result
dell'oggetto, è True
; in caso contrario, result
è False
.
Annotazioni
La Is
parola chiave viene usata anche in Select... Istruzione Case.
Esempio
Nell'esempio seguente viene usato l'operatore Is
per confrontare coppie di riferimenti a oggetti. I risultati vengono assegnati a un Boolean
valore che indica se i due oggetti sono identici.
Dim myObject As New Object
Dim otherObject As New Object
Dim yourObject, thisObject, thatObject As Object
Dim myCheck As Boolean
yourObject = myObject
thisObject = myObject
thatObject = otherObject
' The following statement sets myCheck to True.
myCheck = yourObject Is thisObject
' The following statement sets myCheck to False.
myCheck = thatObject Is thisObject
' The following statement sets myCheck to False.
myCheck = myObject Is thatObject
thatObject = myObject
' The following statement sets myCheck to True.
myCheck = thisObject Is thatObject
Come illustrato nell'esempio precedente, è possibile usare l'operatore Is
per testare gli oggetti con associazione anticipata e tardiva.
Usare l'operatore TypeOf con l'operatore Is
Is
L'operatore può essere usato anche con la TypeOf
parola chiave per creare un'espressione TypeOf
...Is
che verifica se una variabile oggetto è compatibile con un tipo di dati. Per esempio:
If TypeOf sender Is Button Then