Option Default (statement)


Option Default type


Sets the default data type of variables and function return values when not otherwise specified.


By default, the type of implicitly defined variables and function return values is Variant. This statement is used for backward compatibility with earlier versions of BasicScript where the default data type was Integer.

This statement must appear outside the scope of all functions and subroutines.

Currently, type can only be set to Integer.


'This script sets the default data type to Integer. This fact

'is used to declare the function AddIntegers which returns an

'Integer data type.

Option Default Integer

  Function AddIntegers(a As Integer,b As Integer)

  Foo = a + b

  End Function

Sub Main

  Dim a,b,result

  a = InputBox("Enter an integer:")

  b = InputBox("Enter an integer:")

  result = AddIntegers(a,b)

End Sub

See Also

DefType (statement)

More information