A small problem in VB
Long variables are stored as 32-bit (4-byte) signed values.

Its range is from -2 147483648 to 2 147483647.

The type declaration character of Long is ampersand; )

You have a 1279* 140 in the code, which overflows because VB will calculate such numbers according to the most matching type when operating. Here, because 1279 and 140 are both integers, it will operate as an integer, and the range of integers is between -32767 and +32768. Because1279 *140 =179060 is greater than 65535, there is overflow. To calculate correctly, one of the numbers must be converted to a long integer or a data type with a range greater than 179060.

Buffer 2 = buffer1+1279&; * 140

Add a&; Will let VB in the operation according to the long integer operation, will not overflow.