Search This Blog

Thursday 27 October 2011

Files concept "Instr ()" with an Example


Instr( ):-
                        We can use this function to search given word in a line of text. If word was found then it returns true.

                                    Syntax:-   Instr(line of text,”word”)


            EX:-3
                        To find the no:of lines in given file.

                                    Option explicit
                                    Dim fso,fo,l
                                    Set fso=createobject(“scripting.filesystemobject”)
                                    Set fo=fso.opentextfile(“c:\sample.txt”,1,false)
                                    l=0
                                    while fo.atendofstream< >true
                                                fo.readline
                                                l=l+1
                                    wend
                                    print(“no:of lines in the file”&l)
                                    fo.close
                                    set fo=nothing
                                    set fso=nothing


           


No comments:

Post a Comment