Since AfxMessageBox() returns an int you could change your function from void to int return type. Then get a single line exit by

Code:
if(! result)
  return AfxMessageBox(ErrorMsg)