You need to change your data types. Byte is only limited to 0 - 255 and you're working with numbers bigger than that, like 263, 258, etc. And you should never use the Variant data type. It's the number one cause of slowing your program and it takes longer to compute I believe too.