Friday, 13 September 2013

Write a VB Script program to accept a value & check whether it is a numeric or not and display the value is positive or negative

Index.html
--------------------
<html>
<head>
<title>VB Script By Asif</title>
<script language="VBScript">
Sub asif
    Dim TheForm
    Set TheForm=Document.forms("Form1")
    If IsNumeric(TheForm.Text1.Value) Then
        If cint(TheForm.Text1.Value)<0 Then
            MsgBox "This is a Negative number !"
        Else
            MsgBox "This is a Positive number !"
        End If
    Else
        MsgBox "This is a Text !"
    End If
End Sub
</Script>
</head>
<body>
<form name="Form1">
Number1:<input type="text" name="Text1"/><br/>
<input type="button" name="Button1" value="Check"/>
<script for="Button1" event="onClick" language="VBScript">
Call asif
</script>
</form>

</body>
</html>


Input:

5
Output:
This is a Positive number !

Input:
-5
Output:
This is a Negative number !

Input:
A
Output:
This is a Text !

No comments:

Post a Comment