Skip to content

Compile options in VB9 – compare and infer

These options can also be set for all modules in the project settings window, or for each file in code. If the settings are in conflict, the setting written in code overrides the project setting.

Option compare
This option simply tells if strings will be compared case sensitive (option compare text) or binary (option compare binary). So, given that option compare is set to binary, A is set to False, otherwise True.

Dim A As Boolean = (“ABC” = “abc”)

Option infer
This option can be on or off. When infer is set to on, you do not have to type out the data type of a variable when you are declaring it.

This code will make A an Integer, since it is initialized with a integer value, and B a Short, since it is initialized with a short integer value.

Dim A = 1
Dim B = 2S

When option infer is set to off, you must type out the name of the datatype. Either way, the code is still type safe.

Categories: Visual Basic 9.

Tags:

Comment Feed

No Responses (yet)



Some HTML is OK

or, reply to this post via trackback.