Thursday, September 2, 2010

Simple Tasks in VBScript

'Script for checking whether the data is date
somedate = "10/30/99"
msgbox(IsDate(somedate))

'Script for converting a string into upper case and lower case
txt = "Have a nice day!"
msgbox(ucase(txt))
msgbox(lcase(txt))

'Script for removing the spaces before and after the string
name = " Bill "
msgbox("Hello" & trim(name) & "Gates")
msgbox("Hello" & rtrim(name)& "Gates")
msgbox("Hellow"&ltrim(name)&"Gates")

'Script for reversing a string
sometext = "Hello Everyone!"
msgbox(strReverse(sometext))

'Script for rounding a number to nearest integer
i = 48.66776677
j = 48.33333333
msgbox(Round(i))
msgbox(Round(j))

'Script for getting the Left and Right characters from the given string
sometext = "Welcome to our Web Site!!"
msgbox(Left(sometext,5))
msgbox(Right(sometext, 5))

'Script for getting the specified number of characters from the given position
sometext = "Welcome to our Web Site!!"
msgbox(Mid(sometext,6,2))

No comments:

Post a Comment