Monday, 30 September 2013

                                                               
                                                               VB Scripts  

write a script to join the alphabets 

x="a,b+c"
y=Replace(x,",","")
z=Replace(y,"+","")
'Replace(x,"+","")
cn=Len(z)

For i=1 To cn

'If (i Mod 2=0)Then
'Do nothing;
'Else

y=Mid(z,i,1)
msgbox y
'End if


Next

write a script to remove spaces between words

st="he llo"

msgbox Replace(st," ","")


write a script the print array of even numbers in an array

redim a(9)
for i=0 to 9
a(i)=inputbox("enter  a value")
next
for j=0 to 9
if(a(j )mod 2 = 0) then
msgbox j&" th "&a(j)&" is even"
end if
next

write a script to search for string in array of strings(case sensitive)

Dim a(2)
a(0)="Akshay"
a(1)="amir"
a(2)="sajid"
ev="Akshay"
Msg="not found"
For i=0 To ubound(a)
 If a(i)=ev Then
    Msg="found"
  Exit For
 End If
Next
msgbox ev&" "&msg


write a script to sort in array of numbers

dim a(2)
a(0)=3
a(1)=2
a(2)=1
for i=0 to ubound(a)-1
    for j=j+1 to ubound(a)
      if a(i)>a(j) then
       x=a(i)
       y=a(j)
       a(i)=y
       a(j)=x
      end if
   next
next

for i=0 to ubound(a)
    msgbox a(i)
next