Lang L: none (table-of-contents)
IsError kirjeldus
Kasutatakse veaväärtuste kontrollimiseks.
Lihtsad IsError näited
1 | MsgBox IsError (1/2) |
Tulemus: vale
1 | MsgBox IsError (CvErr (0)) |
Tulemus: tõsi
IsError süntaks
VBA redigeerijas saate IsError funktsiooni süntaksi nägemiseks tippida "IsError ("):
Funktsioon IsError sisaldab argumenti:
Väljend: Väljend, mida testitakse.
Näited Excel VBA IsError funktsioonist
123456789101112 | Funktsiooni jagamine (a kui kahekordne, b kui kahekordne)Sees Viga GoTo error_handlerJaga = a / bVälju funktsioonerror_handler:Jaga = CVErr (vea number)LõppfunktsioonAlamviga_näide2 ()MsgBox "IsError (1/2) is" & IsError (Divide (1, 2))MsgBox "IsError (1/0) is" & IsError (Divide (1, 0))End Sub |
Tulemus: IsError (1/2) on vale
IsError (1/0) on tõene
IsErrori abil saate kontrollida Exceli lehe lahtreid.
123456789101112 | AlamkontrollIfError (strRange kui string)Hämardage rakk vahemikunaIga lahtri vahemikus (strRange)cell. Offset (0, 1) = IsError (lahter)EdasiEnd SubAlamviga_näide1 ()CheckIfError "C2: C5"CheckIfError "B9: B12"End Sub |