Although Visual Basic .NET allows you to use variables without declaring them, it is a very unwise practice. Using undeclared variables has several key problems, including:
1. If a variable is not declared, the Visual Basic compiler will guess at its type based on the data that is put into it. Often, this guess causes inefficient type use. Additionally, the Visual Basic compiler has to generate a great deal of handling code to cast variables from one data type to another. This can lead to poor performance, increased program size, and unexpected results.
2. Use of non-declared variables eliminates almost all the benefits of the .NET common type system, which enables cross-language integration, type safety, and high performance code execution.
3. Non-declared variables make code very difficult to understand and debug. For large, complex applications, non-declared variables can result in program code that is indecipherable.
4. Use of non-declared variables makes it easy to inadvertently declare a new variable by mistyping the name of an existing variable.