Historically I've used 'Convert.ToInt32(TextBox1.Text)' when moving the numbers stored in a TextBox to an integer variable. But it's made me wonder what the difference is between Int16, Int32 and Int64. In simple terms, can someone explain this to me (remember, I'm simple minded!)?

As a follow-up question, I'm finding that 'ToInt32' doesn't like decimal places even though the variable is defined as a "Double". I've used 'ToDecimal' to get around this. But is there a better syntax to use when it will be stored in a Database?

As always, thanks for the help.


The number on the end of each function represents the bit count, therefore, represents the maximum value that can be returned by that function ( as Integer )

Int16 - 16bit
Int32 - 32bit
Int64 - 64bit

As for the decimal places, the ToInt32 function returns an integer, which is a whole number. Therefore the decimal value will be rounded.

I agree with Begginnerdev, since Int32 is normal interger, Int16 is "Short" interger, Int64 is "Long" interger.

Take it a little further for me then. Into16: would that be indicative of a numeric value that had 16 places (9,999,999,999,999,999)? Again, I'm just trying to understand why I would use 'ToInt32' as opposed to '16' or '64'. Or better, where would I best use '16' and/or '64'?

Again, thanks for participating in my lesson for the day!


I prefer to avoid the terms ShortInt and LongInt as they vary depending on the architecture. The number refers to the number of bits (binary digits). For example, Int16 is a 16 bit value. To summarize, as beginnerdev said

Int16 - 16 bit - range is -32768 to 32727
Int32 - 32 bit - range is -2,147,483,648 to 2,147,483,647
Int64 - 64 bit - range is -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807

The max value is determined by raising 2 to the power of the number of bits - 1 (because the leftmost bit is a sign bit) then subtracting 1. So for a 16 bit int (signed) the max value is 2**15 - 1 or 32767.

However, if you are only concerned about positive numbers then you can used their unsigned counterparts which do not reserve a sign bit. These are

UInt16 - max value is 2**16 - 1 or 65,535
UInt32 - max value is 2**32 - 1 or 4,294,967,295
UInt64 - max value is 2**64 - 1 or 18,446,744,073,709,551,615
commented: Great example! +8

Rev. Jim, As always, thank you. It seems that, for the most part, Int32 would be the most used is has a range of 4 Billion plus. With what I'm working with, that will suffice with no problems. If I ever do something for Exxon or Mobile, I'll use Int64! LOL!!

Thanks again group!! You guys are the best!