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

Which function is used to perform string comparison?

0 Answers  


what is diff b/n these 2 programs 1) for i=5 to 1 step 2 msgbox "pass" next 2_) for i=5 to 1 step -2 msgbox "pass" next

5 Answers   Hexaware,


Mention how to access array data?

0 Answers  


How to assign a date value to a variable?

0 Answers  


write a vb script create 5 folders test1 test2 test3 test4 test5

3 Answers  






How to insert snapshot during manual scripting in QTP?

1 Answers  


What is event handling in vbscript?

0 Answers  


1)How to test whether items in a weblist are in alphabetical order or not?

1 Answers   TCS,


Can automation testing find ssame no. of bugs what we can find by manual testing?

0 Answers  


Which data type/types are supported by vbscript language and what are their specialties?

0 Answers  


how does vb script help in web page designing? explain with example.

0 Answers  


write script to open Gmail.com, and to write script for entering username and password and show whether the result as pass or fail

2 Answers   Thomson Reuters,


Categories