bene allora
per la funzione if........
la funzione if già di per se assume un operatore logico, cioè if
operatore logico se vero esegue il then se falso esegue l'else.
Mi spiego: se scrivo if Prova then (esegui qualcosa).......else(esegui qualcosa altro).......end if
significa se Prova contiene un valore true (vero) eseguirà qualcosa se false(falso) qualcosa d'altro. Prova può essere o una costante di tipo boleano o un operatore logico come il maggiore o minore o uguale (che a sua volta torna ovviamente o true o false). Quindi se scrivo
if 5>3 then..... siccome 5 è veramente maggiore di 3 allora eseguirà le funzioni di then.
Tornando al nostro esempio da te riportato
se si vuole usare l'if direttamente con una variabile, o costante, boleana si può scrivere semplicemente:
if IsActive(Num) then.......
perchè di per se, essendo il valore ritornato dalla funzione IsActive boleano, è corretta come sintassi. Quindi dove tu scrivi
If Var18=True Then
MsgBox "Vero"
Else
MsgBox "falso"
End If
che è corretto può essere comunque sostituito con:
If Var18 Then
MsgBox "Vero"
Else
MsgBox "falso"
End If
che anche è corretto uguale ma risparmia una comparazione (tempo macchina)
Aggiungo, per comodità di chi volesse, l'elenco delle "costanti" di sistema. Notare che usare o il mnemonico o il valore è la stessa cosa
OUTPUT1 7
OUTPUT2 8
OUTPUT3 9
OUTPUT4 10
OUTPUT5 11
OUTPUT6 12
OUTPUT7 16
OUTPUT8 17
OUTPUT9 18
OUTPUT10 19
OUTPUT11 20
OUTPUT12 21
OUTPUT13 22
OUTPUT14 23
OUTPUT15 24
OUTPUT16 25
OUTPUT17 26
OUTPUT18 27
OUTPUT19 28
OUTPUT20 29
DIGTRIGGER 0
ENABLE1 1
ENABLE2 2
ENABLE3 3
ENABLE4 4
ENABLE5 5
ENABLE6 6
CHARGE 13
CHARGE2 14
CURRENTHILOW 15
XPLUS 0
XMINUS 1
XHOME 2
YPLUS 3
YMINUS 4
YHOME 5
ZPLUS 6
ZMINUS 7
ZHOME 8
APLUS 9
AMINUS 10
AHOME 11
BPLUS 12
BMINUS 13
BHOME 14
CPLUS 15
CMINUS 16
CHOME 17
INPUT1 18
INPUT2 19
INPUT3 20
INPUT4 21
DIGITIZE 22
INDEX 23
LIMITOVER 24
EMERGENCY 25
THCON 26
THCUP 27
THCDOWN 28
OEMTRIG1 29
OEMTRIG2 30
OEMTRIG3 31
OEMTRIG4 32
OEMTRIG5 33
OEMTRIG6 34
OEMTRIG7 35
OEMTRIG8 36
OEMTRIG9 37
OEMTRIG10 38
OEMTRIG11 39
OEMTRIG12 40
OEMTRIG13 41
OEMTRIG14 42
OEMTRIG15 43
TIMING 44
JOGXP 45
JOGXM 46
JOGYP 47
JOGYM 48
JOGZP 49
JOGZM 50
JOGAP 51
JOGAM 52
HOMING 53
PROBING 54
START 55
sperando possa essere stato utile e chiaro