The If operator that you're using is effectively generic, in that the two potential return values must be the same type or one must be a type derived from the other. In your first code snippet, you have this:
vb.net Code:
  1. if(s = " ", Nothing, s)
so that If operator is returning a String, i.e. either a null reference of type String or the value of s. The CType operator is then converting that String reference to a Byte? and it appears that the result of using CType to convert a null String reference to a nullable numeric type is always zero. I tried it with Integer? as well and got the same result. In the second case, because the last argument to If is type Byte?, the second argument is inferred to be that type too, so that Nothing is going directly to type Byte?, rather than to String first and then to Byte?. It seems to be a bit of an idiosyncratic behaviour but it is what it is.