That line doesn't make sense in your original code anyway as you are overwriting handle of a vertex texure with that of a pixel texture. Assignments in an if aren't nice anyway especially when there are more arguments in the condition.But I have a feeling that just using GetSamplerIndex with your constant name will work as D3DXHANDLES are just strings anyway.