Is functions

Last updated
Function availability
Function nameVB 6 [1] [2] VBA [3] VBScript [4] VB .NETT-SQL
IsArrayYesYesYesYesNo
IsDateYesYesYesYesYes
IsDBNullNoNoNoYesNo
IsEmptyYesYesYesNoNo
IsErrorYesYesNoYesNo
IsMissingYesYesNoNoNo
IsNothingNoNoNoYesNo
IsNullYesYesYesNoYes
IsNumericYesYesYesYesYes
IsObjectYesYesYesNoNo
IsReferenceNoNoNoYesNo

The Is functions (also known as data information functions, [5] data inspection functions, [6] or data-testing functions [6] ) are a set of functions in Microsoft's Visual Basic 6, Visual Basic for Applications, VBScript, and Visual Basic .NET. Several of them are also provided in Transact-SQL by the .NET Framework Data Provider for Microsoft SQL Server.

Contents

What the functions do

The functions are simple data validation and data type checking functions. The data validation functions determine whether it is possible to convert or coerce the data value given as an argument to the function to the type implied by the function name, and return a Boolean value recording whether it was possible or not. (Note that the actual data conversion functions, such as Oct() throw exceptions if conversion is not possible. The validation functions allow one to test whether a conversion would fail, and change the program's flow of control in an if statement.) True indicates that conversion would be possible, False indicates that it would not be. Similarly the type checking functions return a Boolean recording whether the argument expression is of a particular type.

In Transact-SQL, the functions return zero or one rather than Boolean values True and False.

IsArray(name)
This function determines whether the variable name passed as its argument is an array. Uninitialized arrays will, note, return False from this function in Visual Basic .NET. [7] In Visual Basic 6, arrays are not reference types, and an uninitialized array will return True from this function just like an initialized array. [8]
IsDate(expression)
This function determines whether the expression passed as its argument can be converted to a variable of type Date, or is already of type Date. Uninitialized variables that are of type Date can of course be converted, despite being uninitialized, so this will always return True for such variables. [9] Note that strings that contain a day of the week in addition to a date (e.g. "Sat, October 12, 2010") will return a failure result. [10] In VBScript and Visual Basic .NET, the conversion process employs the locale settings of Microsoft Windows, meaning that what may parse as a date on one system, configured to use one locale, may fail to parse as a date on another system, configured to use a different locale. [11] [12]
IsDBNull(expression)
This function determines whether the expression passed as its argument evaluates to System.DBNull.Value. [9] This is equivalent to Visual Basic 6's IsNull() function. [10] Note that it is not possible to directly compare an expression for equality to System.DBNull, because any expression of the form x = DbNull will evaluate to DbNull simply because it contains a null. IsDBNull() is the only way to test for equality to System.DBNull. [12]
IsEmpty(expression)
This function determines whether the expression passed as its argument is an uninitialized variant. Note that an uninitialized variant is distinct from a variant that has been initialized to hold Null. [13] Although the function takes an expression, rather than simply a variable name, any expression that isn't simply a variable name is considered not to be an uninitialized variant. [11] This function was available in Visual Basic 6, but has been superseded in Visual Basic .NET by the IsNothing() function. [14] In VBScript, if a variant is assigned Nothing, this function still returns False. [15]
IsError(expression)
This function, in Visual Basic .NET, determines whether the expression passed as its argument is an exception object, i.e. an object of the System.Exception class or one of its subclasses. [7] In Visual Basic 6, the function tests whether the expression is a variant with the special vbError subtype. [16]
IsMissing(name)
This function determines whether the variable name passed as its argument is an optional argument that was not passed to a function by its caller. It returns True only of the variable is a variant that has not been initialized. This function only exists in Visual Basic 6. In Visual Basic .NET, optional parameters are required to have default initializers, and the function no longer exists. [17]
IsNothing(expression)
This function determines whether the expression passed as its argument evaluates to Nothing. [9] It is a simple library function (comprising just 4 CIL instructions) which can itself be written in Visual Basic as: [18] [19]
PublicSharedFunctionIsNothing(ByValExpressionAsObject)AsBooleanReturn(ExpressionIsNothing)EndFunction
The effect of this is to return False for all value (non-reference) expressions, because they will be wrapped up, as part of the function call, into objects, which will by their very natures, not be null objects. [18] [19] To avoid this behaviour, one can use the IS operator to compare an object directly to Nothing, writing expression IS Nothing rather than IsNothing(expression). The compiler will raise a compile-time error if the compared expression is a value rather than a reference type, catching the type mismatch at compile time rather than simply returning False at run-time. [20] Strings are reference types in Visual Basic .NET, and so capable of being null (as opposed to simply zero-length, empty, strings). For such strings, this function returns True. (For empty strings it returns False.) [21] [18]
IsNull(expression)
This function determines whether the expression passed as its argument evaluates to Null. A null value in any sub-expression of the expression causes the entire expression to be considered null. [15]
IsNull(expression1,expression2)
This function, taking two arguments, is specific to Transact-SQL. In contrast to the Visual Basic function by this name, it does not return a Boolean, but instead returns the first expression if that is not NULL, otherwise the second expression. [22] The purpose of the function is to replace any NULL values with another, presumably (but not required to be) non-NULL, value. [23] It is a two-argument version of COALESCE().
IsNumeric(expression)
This function determines whether the expression passed as its argument can be converted to a number (be that a Short, Integer, Long, Single, Double, or Decimal) from a character or string, or is already a number. [24] [25] In Transact-SQL, strings can be converted to numbers even if they contain characters that one might not expect in numbers. This is because Transact-SQL allows conversion from money and smallmoney types to numbers, and monetary data in string form may contain currency indicator characters such as the '£' or '$' symbols. [26] The same is true of VBScript, where any string that can be converted to a currency value in the current locale is considered to be numeric. VBScript does not, however, consider dates and times to be numeric. [27]
IsObject(expression)
This function determines whether the expression passed as its argument is an object rather than a value. [4] This is equivalent to Visual Basic .NET's IsReference() function. [10]
IsReference(expression)
This function determines whether the expression passed as its argument is a reference rather than a value. [24] This is equivalent to Visual Basic 6's IsObject() function. [10]

Related Research Articles

VBScript is an Active Scripting language developed by Microsoft that is modeled on Visual Basic. It allows Microsoft Windows system administrators to generate powerful tools for managing computers without error handling and with subroutines and other advanced programming constructs. It can give the user complete control over many aspects of their computing environment.

<span class="mw-page-title-main">Visual Basic (.NET)</span> Object-oriented computer programming language

Visual Basic (VB), originally called Visual Basic .NET (VB.NET), is a multi-paradigm, object-oriented programming language, implemented on .NET, Mono, and the .NET Framework. Microsoft launched VB.NET in 2002 as the successor to its original Visual Basic language, the last version of which was Visual Basic 6.0. Although the ".NET" portion of the name was dropped in 2005, this article uses "Visual Basic [.NET]" to refer to all Visual Basic languages released since 2002, in order to distinguish between them and the classic Visual Basic. Along with C# and F#, it is one of the three main languages targeting the .NET ecosystem. Microsoft updated its VB language strategy on 6 Feb 2023 stating that VB is a stable language now and Microsoft will keep maintaining it.

In computer programming, a parameter or a formal argument is a special kind of variable used in a subroutine to refer to one of the pieces of data provided as input to the subroutine. These pieces of data are the values of the arguments with which the subroutine is going to be called/invoked. An ordered list of parameters is usually included in the definition of a subroutine, so that, each time the subroutine is called, its arguments for that call are evaluated, and the resulting values can be assigned to the corresponding parameters.

In computer programming, the ternary conditional operator is a ternary operator that is part of the syntax for basic conditional expressions in several programming languages. It is commonly referred to as the conditional operator, ternary if, or inline if. An expression a ? b : c evaluates to b if the value of a is true, and otherwise to c. One can read it aloud as "if a then b otherwise c". The form a ? b : c is by far and large the most common, but alternative syntaxes do exist; for example, Raku uses the syntax a ?? b !! c to avoid confusion with the infix operators ? and !, whereas in Visual Basic .NET, it instead takes the form If(a, b, c).

This article compares two programming languages: C# with Java. While the focus of this article is mainly the languages and their features, such a comparison will necessarily also consider some features of platforms and libraries. For a more detailed comparison of the platforms, see Comparison of the Java and .NET platforms.

In computer science, the Boolean is a data type that has one of two possible values which is intended to represent the two truth values of logic and Boolean algebra. It is named after George Boole, who first defined an algebraic system of logic in the mid 19th century. The Boolean data type is primarily associated with conditional statements, which allow different actions by changing control flow depending on whether a programmer-specified Boolean condition evaluates to true or false. It is a special case of a more general logical data type—logic does not always need to be Boolean.

A user-defined function (UDF) is a function provided by the user of a program or environment, in a context where the usual assumption is that functions are built into the program or environment. UDFs are usually written for the requirement of its creator.

C++/CLI is a variant of the C++ programming language, modified for Common Language Infrastructure. It has been part of Visual Studio 2005 and later, and provides interoperability with other .NET languages such as C#. Microsoft created C++/CLI to supersede Managed Extensions for C++. In December 2005, Ecma International published C++/CLI specifications as the ECMA-372 standard.

<span class="mw-page-title-main">C Sharp (programming language)</span> Programming language

C# is a general-purpose high-level programming language supporting multiple paradigms. C# encompasses static typing, strong typing, lexically scoped, imperative, declarative, functional, generic, object-oriented (class-based), and component-oriented programming disciplines.

In computing, IIf is a function in several editions of the Visual Basic programming language and ColdFusion Markup Language (CFML), and on spreadsheets that returns the second or third parameter based on the evaluation of the first parameter. It is an example of a conditional expression, which is similar to a conditional statement.

C# and Visual Basic .NET are the two primary languages used to program on the .NET Framework.

Nullable types are a feature of some programming languages which allow a value to be set to the special value NULL instead of the usual possible values of the data type. In statically typed languages, a nullable type is an option type, while in dynamically typed languages, equivalent behavior is provided by having a single null value.

<span class="mw-page-title-main">Visual Basic (classic)</span> Event-driven programming language

The original Visual Basic is a third-generation event-driven programming language from Microsoft known for its Component Object Model (COM) programming model first released in 1991 and declared legacy during 2008. Microsoft intended Visual Basic to be relatively easy to learn and use. Visual Basic was derived from BASIC and enables the rapid application development (RAD) of graphical user interface (GUI) applications, access to databases using Data Access Objects, Remote Data Objects, or ActiveX Data Objects, and creation of ActiveX controls and objects.

Variant is a data type in certain programming languages, particularly Visual Basic, OCaml, Delphi and C++ when using the Component Object Model. It is an implementation of the eponymous concept in computer science.

Entity Framework (EF) is an open source object–relational mapping (ORM) framework for ADO.NET. It was originally shipped as an integral part of .NET Framework, however starting with Entity Framework version 6.0 it has been delivered separately from the .NET Framework.

The null coalescing operator is a binary operator that is part of the syntax for a basic conditional expression in several programming languages, including C#, PowerShell as of version 7.0.0, Perl as of version 5.10, Swift, and PHP 7.0.0. While its behavior differs between implementations, the null coalescing operator generally returns the result of its left-most operand if it exists and is not null, and otherwise returns the right-most operand. This behavior allows a default value to be defined for cases where a more specific value is not available.

This article describes the syntax of the C# programming language. The features described are compatible with .NET Framework and Mono.

Language Integrated Query is a Microsoft .NET Framework component that adds native data querying capabilities to .NET languages, originally released as a major part of .NET Framework 3.5 in 2007.

<span class="mw-page-title-main">XLeratorDB</span>

XLeratorDB is a suite of database function libraries that enable Microsoft SQL Server to perform a wide range of additional (non-native) business intelligence and ad hoc analytics. The libraries, which are embedded and run centrally on the database, include more than 450 individual functions similar to those found in Microsoft Excel spreadsheets. The individual functions are grouped and sold as six separate libraries based on usage: finance, statistics, math, engineering, unit conversions and strings. WestClinTech, the company that developed XLeratorDB, claims it is "the first commercial function package add-in for Microsoft SQL Server."

The syntax of the SQL programming language is defined and maintained by ISO/IEC SC 32 as part of ISO/IEC 9075. This standard is not freely available. Despite the existence of the standard, SQL code is not completely portable among different database systems without adjustments.

References

What supports what

Sources used

  • Harris, Matthew (1999). Sams teach yourself Microsoft Excel 2000 programming in 21 days. Sams Teach Yourself Series. Sams. ISBN   978-0-672-31543-5.
  • Israel, Marc; Jones, J. Steven (2001). MCSE: SQL Server 2000 design study guide. Certification Study Guide Series. John Wiley and Sons. ISBN   978-0-7821-2942-7.
  • Knittel, Brian (2002). "VBScript Reference". Windows XP under the hood. Que Publishing. ISBN   978-0-7897-2733-6.
  • Lomax, Paul; Childs, Matt; Petrusha, Ronald (2003). VBScript in a nutshell. In a Nutshell (2nd ed.). O'Reilly Media, Inc. ISBN   978-0-596-00488-0.
  • Marcus, William; Levy, Alex (2002). Visual Basic 6 Programming. Tata McGraw-Hill. ISBN   978-0-07-040290-4.
  • Perry, Greg M.; Hettihewa, Sanjaya (1998). Sams teach yourself Visual Basic 6 in 24 hours . Teach Yourself in 24 Hours Series (2nd ed.). Sams Publishing. ISBN   978-0-672-31533-6.
  • Petroutsos, Evangelos (2002). Mastering Visual Basic.NET. Mastering Series. John Wiley and Sons. ISBN   978-0-7821-2877-2.
  • Petrusha, Ronald (2006). Visual Basic 2005: the complete reference. McGraw-Hill Professional. ISBN   978-0-07-226033-5.
  • Price, Jason (2003). Mastering C# database programming. John Wiley and Sons. ISBN   978-0-7821-4183-2.
  • Roman, Steven; Petrusha, Ron; Lomax, Paul (2002a). VB.NET Language Pocket Reference. O'Reilly Media, Inc. ISBN   978-0-596-00428-6.
  • Roman, Steven; Petrusha, Ron; Lomax, Paul (2002b). VB.NET Language in a Nutshell. In a Nutshell (2nd ed.). O'Reilly Media, Inc. ISBN   978-0-596-00308-1.
  • Steele, Patrick (2005-05-31). "IsNothing? Definitely!". Patrick Steele's .NET Blog.
  • Steele, Patrick (2005-06-03). "Avoiding IsNothing()". Patrick Steele's .NET Blog.
  • Wakefield, Cameron; Sonder, Henk-Evert (2001). Lee, Wei Meng (ed.). VB.net Web developer's guide. Syngress. ISBN   978-1-928994-48-0.
  • "ISNUMERIC (Transact-SQL)". MSDN: SQL Server 2008: Transact-SQL Reference. Microsoft.

Further reading

Microsoft's on-line documentation

Other