I have a 64 bit system. I”m declaring my variables as 64 bit variables expecting my code to run faster. When I do functions such as ‘String.IndexOf(“J”, X)’, it fails because X is a Long but it is looking for a 32 bit value as the start index.
Is there any way to pass a 64 bit variable without converting it down to a 32 bit?
You got the wrong idea about 64-bit code. The arguments to the String.IndexOf() method do not change, the second argument is still an Integer. The only type in .NET that changes size is IntPtr.
This is all very much by design. A 64-bit processor does not execute code faster when you let it manipulate 64-bit integral values. Quite the contrary, it makes it run slower. Processor speed is throttled in large part by the size of the caches. The CPU caches are important because they help avoid the processor having to read or write data from RAM. Which is very slow compared to the speed of the processor. A worst-case processor stall from not having data in the L1, L2 or L3 caches can be 200 cycles.
The cache size is fixed. Using 64-bit variables makes the cache half as effective.
You also make your code slower by using Long and Option Strict Off. That requires the compiler to emit a conversion to cast the Long to an Integer. It is not visible in your code but it certainly is performed, you can see it when you look at the IL with ildasm.exe or a decompiler like ILSpy or Reflector.