Write a program to print all lines that contains a word either “testing” or “qtp”

Answers were Sorted based on User's Feedback



Write a program to print all lines that contains a word either “testing” or “qtp&r..

Answer / amit

''' Write a program to print all lines that contains a word either “testing” or “qtp”




Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")




Set objFile = fso.OpenTextFile("C:UsersAmit MoolchandaniDesktop est.txt",1,True)












Do While objFile.AtEndOfStream <> True
str = objFile.ReadLine
If Instr(1,str,"Testing",1) Or Instr(1,str,"qtp",1) Then
Print str
End If




Loop




objFile.Close




Set objFile = Nothing
Set fso = Nothing

Is This Answer Correct ?    5 Yes 0 No

Write a program to print all lines that contains a word either “testing” or “qtp&r..

Answer / syamala usha

set fso = createobject("scripting.filesystemobject")

set f=fso.opentextfile("C:
otes HP.txt",1)


Do until f.atendofstream

str=f.readline

a = split(str," ")

flag=0

for j = 0 to ubound(a)

if (a(j) = "testing") or (a(j) = "qtp") then

flag=1

exit for

end if

next

if flag=1 then

msgbox str

end if

loop

f.close

set f= nothing

set fso =nothing

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More VB Script Interview Questions

can anyone send me a vb scripts code for clicking on a link and coming back on home page again does the same for many links on a web page.

0 Answers   Synechron,


Explain the adodb.stream class?

0 Answers  


What are the disadvantages of vbscript?

0 Answers  


how to write validation function for date in vb script

0 Answers  


write a vb script to generate the following pattern ***** **** *** ** *

7 Answers   Blue Star,


If we take 2 strings as “good” and “bad” then what will ‘+’ and ‘&’ operators return?

0 Answers  


write a vb script to rename a folder from tree4 to tree7

3 Answers  


join all the array values without using join function?

1 Answers   CSS Corp,


print the array values in ascending order?

2 Answers   CSS Corp,


What is wrong with the following code: <%afname="header.asp"%><!?#include file ="<%=afname%>"?>

1 Answers  


What methods are used to create text files and open text files in the vbscript language?

0 Answers  


What is the main difference between function and sub-procedure?

0 Answers  


Categories