Talk:Visual Basic .NET/Variables

Question Re: Default Data Types

In the Using Variables section it mentions the following (incorrect?) examples... bytMyVariable = 1 sbytMyVariable = -2 ... intMyVariable = 100

I find this kinda confusing. how does the compiler know if its sposed to be a byte, sbyte or integer? it cant tell only based on the value coz the value 1 and 100 is valid for all (byte, sbyte and integer) and the value -2 is valid for both sbyte and integer. It mentions in the previous paragraph: "Integral literals, such as 42 and 1000, are of type Integer by default" So according to this all three (bytMyVariable, sbytMyVariable and intMyVariable) should be of type integer. am i right? assuming that is correct, it also implies that it is impossible to have a variable of type byte or sbyte w/o an explicit type declaration statement like: Dim bytMyVariable As Byte = 1 or Dim sbytMyVariable As SByte = -2. Any thots?

Answer:

For those examples, I believe that you would be correct if those variables were declared as generic Object types. I believe that the intention of the example is to show how variables can be assigned values when they have been declared with the types indicated in their variable names.

I would suggest that the examples be changed to include the declaration statements as suggested by the previous commenter.

Question Re: Constant Examples

The code snippet that reads: Const cnstRadToDeg As Single = 57,29579143 Should that not be a '.' instead of a ','?