Tuesday 21 April 2015

VB Script


VB Script Examples :

Q1.print this pattern

54321
5432
543
54
5
ans1:

strVal = 54321
For IntCounter = len(strVal) to 0 step -1
msgbox Left(strVal,IntCounter)
Next


ans2: (or)

strVal = 54321
for IntIcounter = len(strVal) to 1 step -1
strInd= Left(strVal,IntIcounter)
strFinal = strFinal + strInd &VBCRLF
Next
msgbox strFinal

Q2: print hits pattern


54321
4321
321
21
1

ans:

strVal = 54321
For IntCounter = len(strVal) to 0 step -1
msgbox right(strVal,IntCounter)
Next


Q3: print hits pattern

1
12
123
1234
12345


ans:

str="12345"
lstring=len(str)
for i=1 to lstring
msgbox mid("12345",1,i)
next

Q4: print htis pattern


*
**
***
****
*****

ans:

str="*****"
lstring=len(str)
for i=1 to lstring
msgbox mid("*****",1,i)
next

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.