Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to open a text file through VB scripting.?
#1
Not Solved Exclamation 
HI,
The AUT which I have a tree structure. it is a very big one. So What I am planning is to give the names of the links in that tree structure with a unique identifier in a text file with a variable that links the element.

ie, For eg:
In text file I wl give for one link "Photos" as

scn_pic<space>Photos<space>a

Here scn_pic is the unique ID and Photos is the name and a is the variable that tells me this is the link where I have to click. So in that way I wl be linking the whole tree structure with a variable.
The variable a should be given as a parameter in the test case through an excel.

Actually I want to open this text file and parse it to get the info required.
Can anybody help here to get me a QTP vb scripting. Or please suggest a different way.

Thanks
Vivek
Reply
#2
Not Solved
Hi All,
Please let me know if I have to provide more info on this.

Kindly help me..

Thanks
Vivek
Reply
#3
Not Solved
Hi Vivek,

Not sure if I understood your query correctly. But let me give it a try. You intend to store the link name in a text file and then parse the text file to get the detail and then use it to identify the link.

If this is what you intend to do, you can try the following piece of code.

'************************************************************************

Code:
Option Explicit

Dim i, fileName, resultArr

Function readLinkName(ByVal fileName)

    Dim resArr(7)

    Dim objFSO, objFile, lineItem, i

    i = 0

    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile(fileName)

    Do Until objFile.AtEndOfStream
        lineItem = objFile.ReadLine
        resArr(i) = split(lineitem," ")(2)
        i = i +1
    Loop

    readLinkName = resArr

End Function

fileName = "E:\InputFolder\InputFile.txt"

resultArr = readLinkName(fileName)

For i = 0 to UBound(resultArr) - 1
    MsgBox resultArr(i)
Next

'************************************************************************

Let me know if this is what you intended to do and if this works as you expect it to.

The input file is in the following format as you had specified.

unique_id1 Link1 A
unique_id2 Link2 B
unique_id3 Link3 C
unique_id4 Link4 D
unique_id5 Link5 E
unique_id6 Link6 F
unique_id7 Link7 G

Thank You,
Ravi Shankar
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  VB Scripting spixol 0 1,257 12-15-2019, 01:14 PM
Last Post: spixol
  VB scripting Aisha2015 0 2,279 08-07-2015, 02:21 PM
Last Post: Aisha2015
  Regarding Shell Scripting demoqtp 2 4,071 03-31-2015, 12:34 AM
Last Post: demoqtp
  How to read a text file using FSO from bottom to up order?? vallalarasu.p 0 2,376 10-13-2014, 11:14 AM
Last Post: vallalarasu.p
  how to create text file swayam 1 2,679 05-29-2014, 01:25 PM
Last Post: basanth27

Forum Jump:


Users browsing this thread: 1 Guest(s)