Pages

Tuesday, April 19

Running vbscript code without QTP

Hello friends!

Here we will see how to execute vbscipt code without having QTP on your machine!!

Really?? How??

Okey..

1. Just copy n paste below code to new notepad...


'To extract a number from alphanumeric text string
Dim mystring, myLength
mystring = "qtpschools567test12398ing"
myLength = Len(mystring)

For i = 1 To myLength
    If Asc(Mid(mystring, i, 1)) <> 32 Then
        If Asc(Mid(mystring, i, 1)) >= 48 And Asc(Mid(mystring, i, 1)) <= 57 Then
            myNumber = myNumber & Mid(mystring, i, 1)
        End If
    Else
        msgbox("no numeric")
    End If
Next

msgbox(myNumber)


2. Save file as "test.vbs" (with double quotes)
3. It'll display like this on your hard drive..
4. Now close the file and double click on the file icon.
and it's done!! :)

Please note that it'll work only if you don't have any object in your script.
In case of any queries, plz post your comments.

10 comments:

  1. sai: Its working, thanks man.

    ReplyDelete
  2. what does Asc mean and what are the values 32,48,57

    ReplyDelete
    Replies
    1. Asc Function in VB Scripting is used to return the character Ascii Code for the character.

      Delete

  3. @Kiran-
    The Asc function converts argument to ANSI code.

    please refer for details -
    http://msdn.microsoft.com/en-us/library/xfw01fx4%28v=vs.84%29.aspx

    ReplyDelete
  4. for all programs we can write like this

    ReplyDelete
  5. I think its not possible , its only for vb scripting , and file system , excel .. ect

    ReplyDelete
  6. Hi ,
    What does myNumber does here.Can anyone explain the function in does here

    ReplyDelete
    Replies
    1. myNumber is a variable to store the Numeric values which come from the string.

      Delete
  7. How to identify Web elements (link,button) and write scripts and execute without using qtp

    ReplyDelete