dcsimg
June 19, 2018
Hot Topics:

My Favourite Functions - Part 1

  • November 17, 2002
  • By Karl Moore
  • Send Email »
  • More Articles »

IsNumeric Function

You can check if a string or variant is a number by using the IsNumeric() function. Here's how it works:

If IsNumeric(Text1.Text) = True Then   MsgBox("That's a number!")Else   MsgBox("That is NOT a number!")End If

You can use IsDate() in much the same way.

-- "Micro" Maria, Ohio.

Remove Redundant Spaces

The Trim() function is one of my favourites. It removes all the leading and trailing spaces within a string. It goes like this:

MsgBox Trim( _ "  this is my string with surrounding spaces  ")

And it returns "this is my string with surrounding spaces", minus the excess baggage! Very useful indeed.

-- James Matthews, an MCP from Down Under.

Is your Program Running Twice?

Check out the PrevInstance property of the intrinsic App object to check if an instance of your program is currently running. Here's a code snippet:

If App.PrevInstance = True Then   MsgBox "Application already running!"   EndEnd If

-- Peter Potter, Anonymous-by-the-Sea

Extracting Numbers

You can use the Val() function to extract numbers from a string, like this:

MsgBox Val("40 years old")

This returns the number 40. Basically, if it sees a number at the beginning of the string, it carries on and grabs it all. If it finds no number at the beginning, it returns 0.

-- Ben Davis, Teenage Programmer from Istanbul.





Page 2 of 4



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

By submitting your information, you agree that developer.com may send you developer offers via email, phone and text message, as well as email offers about other products and services that developer believes may be of interest to you. developer will process your information in accordance with the Quinstreet Privacy Policy.

Sitemap

×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date