VB.NET is the boutique in .NET, the soul in C # in C #, combined with both power, huh, huh, see how you want to play it, write a simple example to explain how to combine VB.NET with C #.
VB.NET:
In VB.NET, there is a function of Microsoft.visualBasic.iNUMERIC to verify that it is a number, and in C #, you can judge yourself, you can try, you can use the regular expression, but it is too much trouble.
In a project, create a category library as a development language in VB.NET, the code is as follows:
Public
Class Validator
Class Validator Public Function Validate () Function Validate (Byval Str As String) AS Boolean IF (Microsoft.VisualBasic.isNumeric (STR)) THEN RETURN TRUE ELSE RETURN FALSE END IF End Functionend Class
Built a new project in C #, reference the DLL above, the code is as follows:
Validatenumber.validator ValidateObj
=
New
Validatenumber.validator ();
IF
(ValidateObj.validate (TextBox.Text))
{Dataobj.getProductQty = int.parse (TextBox.Text);
Else
{lblmsg.text = "Please enter a number, please try again"; Return;}
Example, don't say more.
Posted on Saturday, September 18, 2004 4:15 PM
The ISNUMERIC in VB is implemented as follows:
Public Static Bool IsNuMeric (Object Expression)
{
BOOL flag1;
IConvertible Convertible1 = NULL;
IF (Expression is iconvertible)
{
Convertible1 = (iconvertible) Expression;
}
IF (convertible1 == null)
{
IF (Expression is char [])
{
Expression = new string ((char []) expression;
}
Else
{
Return False;
}
}
Typecode code1 = convertible1.gettypecode ();
IF ((Code1! = Typecode.String) && (code1! = typecode.char))
{
Return utils.isNumericTypecode (CODE1);
}
String text1 = convertible1.toString (null);
Try
{
Long Num2;
IF (! StringType.ishexorOctValue (Text1, Ref Num2)
{
Double Num1;
Return Doubletype.TryParse (Text1, Ref Num1);
}
Flag1 = True;
}
Catch (Exception)
{
FLAG1 = FALSE;
}
Return flag1;
}