Friday, 6 September 2013

Write a VB Script to show this figure 1

Write a VB Script to show this figure:
* ***1****
***121***
**12321**
*1234321*
123454321

Index.html
<html>
<head>
<title>
VBScript By Asif
</title>
<SCRIPT LANGUAGE="VBScript">
Sub asif
                Dim i,j,x,k
                Dim TheForm
                Set TheForm=Document.forms("Form1")
                If IsNumeric(TheForm.Text1.Value) Then
                                x=TheForm.Text1.Value
                                for i=1 to x
                                                for k=x-1 to i Step -1
                                                                document.write("*")
                                                next
                                                for j=1 to i
                                                                document.write(j)
                                                next
                                                for k=i-1 to 1 Step -1
                                                                document.write(k)
                                                next
                                                for k=x-1 to i Step -1
                                                                document.write("*")
                                                next
                                                document.write("<br/>")
                                Next
                Else
                                MsgBox "Wrong Input!"
                End If
End Sub
</SCRIPT>
</head>
<body>
<FORM NAME="Form1">
<input type="Text" name="Text1"><br/>
<INPUT TYPE="button" NAME="Button1" VALUE="View Figure"><br/>
<SCRIPT FOR="Button1" EVENT="onClick" LANGUAGE="VBScript">
                Call asif
</SCRIPT>
</FORM>
</body>
</html>
Output:
****1****
***121***
**12321**
*1234321*

123454321

No comments:

Post a Comment