VB6 Tutorial 39: Data Inspection Functions

Posted On 2018-04-23 by VB6Boy
Keywords:
Tags: VB6 Tutorials 
Views: 47


Looking for the more of the VB6 Tutorial? Here is the tutorial index.

You'll learn about some data inspection functions in this lesson. These functions will inspect the expression. More precisely, these functions will provide you the information related to your expression. You'll get these functions in the Object Browser inside the "Information" module.

In this lesson, we'll be learning about the following functions:

  • IsNumeric
  • IsArray
  • IsDate
  • IsEmpty
  • IsObject
  • TypeName
  • IsError
  • IsMissing
  • IsNull

IsNumeric

The IsNumeric function returns Boolean value, returns True if an expression can be evaluated to a number.

This function is useful when you want your users to enter only the numeric values in the required field.

Example

Private Sub cmdCheck_Click()
    If IsNumeric(txtField.Text) = True Then
        MsgBox "Value accepted"
    Else
        MsgBox "Please enter a numeric value"
    End If
End Sub

IsArray

The IsArray function returns a Boolean value, returns True if the variable is an array. When you want to check whether a particular variable is an array, the IsArray function is useful.

Example

Dim team(20) As Integer
If IsArray(team) = True Then
    MsgBox "This is an array"
Else
    MsgBox "This is NOT an array"
End If

IsDate

The IsDate function returns a boolean value, returns True if an expression is a date.

Example

Dim dt As Date

dt = 20 / 20 / 2013

If IsDate(dt) = True Then
    MsgBox "This is a date"
Else
    MsgBox "This is NOT a date"
End If

IsEmpty

The IsEmpty function returns True if a variable has not been initialized.

Example

Take a variant variable score.

If IsEmpty(score) = True Then
        MsgBox "Not initialized"
    Else
        MsgBox "Initialized"
End If

IsObject

The IsObject function returns True if the variable is of Object type.

Example

Dim frm As Form
 
If IsObject(frm) = True Then
    MsgBox "Object variable"
Else
    MsgBox "This is NOT an object variable"
End If

TypeName

Returns the datatype of the variable.

Example

Dim n As Integer
n = 34
Dim str As String
str = TypeName(n)
MsgBox str

IsError

Returns True if an expression is an error value.

IsMissing

Returns True if an optional argument has not been passed.

IsNull

Returns True if an expression doesn't contain any valid data.

Related topics


About the Author

has posted a total of 78 articles.


Comments On This Post

No comments on this post yet!


Do you have a thought relating to this post? You can post your comment here. If you have an unrelated question, you can use the Q&A section to ask it.

Or you can drop a note to the administrators if you're not sure where you should post.


Your IP address is:54.166.212.152

Before you can post, you need to prove you are human. If you log in, this test goes away.


Code Links