Friday, 13 September 2013

Write a VB Script program to accept the number from user then print the summation of the digit

index.html
------------------


<html>
<head>
<title>VB Script By Asif</title>
<script language="VBScript">
Sub asif
Dim c,a,b
Dim TheForm
Set TheForm=Document.forms("Form1")
If IsNumeric(TheForm.Text1.Value) and IsNumeric(TheForm.Text2.Value) Then
a=cint(TheForm.Text1.Value)
b=cint(TheForm.Text2.Value)
c=a+b
document.write("Result: " & a & "+" & b & "=" & c)
Else
MsgBox "Wrong Input!"
End If
End Sub
</Script>
</head>
<body>
<form name="Form1">
Number1:<input type="text" name="Text1"/><br/>
Number2:<input type="text" name="Text2"/><br/>
<input type="button" name="Button1" value="ADD"/>
<script for="Button1" event="onClick" language="VBScript">
Call asif
</script>
</form>

</body>
</html>
Output:
----------------
Result: 5+6=11

No comments:

Post a Comment