'This method capture the desktop Screen capture.
Desktop.CaptureBitmap "C:\TempSS.png",true
'If you want to capture your application, then use syntax like B().CaptureBitmap
Set objWord=createobject("Word.Application")
objWord.Documents.Open("C:\Test.doc")
objWord.Application.Selection.InlineShapes.AddPicture("C:\TempSS.png")
objWord.ActiveDocument.Save
'objWord.ActiveDocument.SaveAs("1.doc")
objWord.ActiveDocument.Close
Set objWord=nothing
Wednesday, September 5, 2012
How to reverse a string without using any built-in function
As per the question/requirement you should not use any built-in methods like mid, instr etc.
We can reverse the string using the regular expression.
Find the script below:
'The below script prints the input string in reverse order without using any built-in methods
str="Hello Uday"
Set regExpObj=new RegExp
regExpObj.pattern="[a-z A-Z]"
regExpObj.global=true
Set matches=regExpObj.execute(str)
For each letter in matches
result=letter.value&result
Next
print result
The above code prints "yadU olleH"
Actually i got this code from one netizen, but i didnt understand the logic when i look at it. Then i started nailing down the logic.
Here is how it goes:
The regular expression "[ ]" stands for matches one character in a list at a time, so [a-z A-Z] bring only one character from "a-z" or "A-Z".
So upon executing this regular expression did you see there are 10 characters(length of the string).
So in the next for loop we are iterating through these 10 characters from 1-10.
Because we are appending the the new character to the result, the first char will become last and second character becomes last but one and so on.
At the end of the loop, you will get the reversed string.
I hope you will be clear now.
We can reverse the string using the regular expression.
Find the script below:
'The below script prints the input string in reverse order without using any built-in methods
str="Hello Uday"
Set regExpObj=new RegExp
regExpObj.pattern="[a-z A-Z]"
regExpObj.global=true
Set matches=regExpObj.execute(str)
For each letter in matches
result=letter.value&result
Next
print result
The above code prints "yadU olleH"
Actually i got this code from one netizen, but i didnt understand the logic when i look at it. Then i started nailing down the logic.
Here is how it goes:
The regular expression "[ ]" stands for matches one character in a list at a time, so [a-z A-Z] bring only one character from "a-z" or "A-Z".
So upon executing this regular expression did you see there are 10 characters(length of the string).
So in the next for loop we are iterating through these 10 characters from 1-10.
Because we are appending the the new character to the result, the first char will become last and second character becomes last but one and so on.
At the end of the loop, you will get the reversed string.
I hope you will be clear now.
Subscribe to:
Posts (Atom)