Validity Check like PDoxwin's

I would like to code like Pdoxwin's way of validity check in
the ChangeValue method.
In Pdoxwin, it's something like this :

var
        sOld    string
        sNEw    string
endVar
        sOld = self.value
        doDefault
        sNew = self.value

        .. some checking rountine ..

        if invalid then
                self = sOld
                eventInfo.setErrorCode( cannotDepart )
                msgInfo("Invalid","Wrong Code")
        endif

Anyone know how to do this in Delphi ?

Thanks