Friday, 6 September 2013

Write a VB Script to show this figure 6

Write a VB Script to show this figure:
          1
        212
      32123
    4321234
  543212345
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 to i Step -1
                                                                document.write("&nbsp;&nbsp;")
                                                next
                                                for k=i to 2 Step -1
                                                                document.write(k)
                                                next
                                                for j=1 to i
                                                                document.write(j)
                                                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
        212
      32123
    4321234
  543212345


No comments:

Post a Comment