Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to check if string or boolean

Status
Not open for further replies.

TonyScarpelli

Programmer
Jan 23, 2003
361
US
I'm looking for a function that can tell me if a string is a string or not, and a boolean is a boolean or not.

In FoxPro we have a Type() function that does that.

Is there something equivalent in VB.Net?

Thanks.


Tony Scarpelli
Clinical Engineering Dept.
Maine Medical Center
Portland, Maine 04102
 
Since .NET is strongly typed, a variable of type Boolean will always contain values that are appropriate to it's datatype. So you are guaranteed to always get either "true" or "false" out of one.

Same thing applies to a String. It will always contain a string value (or String.Empty). Note that a string value can be a string representation of other datatypes (since you can call ToString() on anything), but it's still a valid string.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Ahh, you're right. I had forgotten that string is a reference type, not a value type like Boolean.

So, there is a chance that it could be Nothing/null.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top