VB Script IF Statement

Below is my code. Noobie question here. I am sure this is easier than I am thinking and its probably just a simple end but just wanting to make sure I do it right. After " if fnamelog = "inj-r" or fnamelog = "log-r" or fnamelog = "ros-r" then" I just want the program to do nothing if it find filenames with these last 5 characters and move on to the else. Is this a simple as putting in an end?


=============
CODE
=============

Set objTextStream = objFSO.OpenTextFile(objFolder & "\" & file.Name)
 fname = left(file.name,11)
 fnamelog = right(file.name,5)
 if fnamelog = "inj-r" or fnamelog = "log-r" or fnamelog = "ros-r" then
      


 else fname = "BC-BBA-PRVW" or fname ="BC-BBN-PRVW" or fname ="BC-BBM-PRVW" or fname ="BC-BBA-RCPS" or fname = "BC-BBN-RCPS" or fname ="BC-BBM-RCPS" or fname ="BC-BBA-LGNS" or fname ="BC-BBN-LGNS" or fname ="BC-BBM-LGNS" then
      Do While Not objTextStream.AtEndOfStream
            a1=objTextStream.ReadLine
            j=instr(trim(a1),"TEXT.dtd")
            x=instr(trim(a1),".dtd")
          if j > 0 then
LVL 3
jsuttorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

EDDYKTCommented:
then don't put the line in

i.e.


if  fname = "BC-BBA-PRVW" or fname ="BC-BBN-PRVW" or fname ="BC-BBM-PRVW" or fname ="BC-BBA-RCPS" or fname = "BC-BBN-RCPS" or fname ="BC-BBM-RCPS" or fname ="BC-BBA-LGNS" or fname ="BC-BBN-LGNS" or fname ="BC-BBM-LGNS" then
     Do While Not objTextStream.AtEndOfStream
          a1=objTextStream.ReadLine
          j=instr(trim(a1),"TEXT.dtd")
          x=instr(trim(a1),".dtd")
         if j > 0 then
...
0
BrianGEFF719Commented:
if seems are are no other cases...so why not...


if NOT (fnamelog = "inj-r" or fnamelog = "log-r" or fnamelog = "ros-r") then
'...
 Do While Not objTextStream.AtEndOfStream
          a1=objTextStream.ReadLine
          j=instr(trim(a1),"TEXT.dtd")
          x=instr(trim(a1),".dtd")
         if j > 0 then



-Brian
0
EDDYKTCommented:
if that is sub or function then

use exit sub or exit function

i.e.

if fnamelog = "inj-r" or fnamelog = "log-r" or fnamelog = "ros-r" then
     
exit function ' i assume that is function

 else fname = "BC-BBA-PRVW" or fname ="BC-BBN-PRVW" or fname ="BC-BBM-PRVW" or fname ="BC-BBA-RCPS" or fname = "BC-BBN-RCPS" or fname ="BC-BBM-RCPS" or fname ="BC-BBA-LGNS" or fname ="BC-BBN-LGNS" or fname ="BC-BBM-LGNS" then
     Do While Not objTextStream.AtEndOfStream
          a1=objTextStream.ReadLine
          j=instr(trim(a1),"TEXT.dtd")
          x=instr(trim(a1),".dtd")
         if j > 0 then
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

EDDYKTCommented:
should it be

if NOT (fnamelog = "inj-r" and fnamelog = "log-r" and fnamelog = "ros-r") then

reverse the logic?
0
EDDYKTCommented:
forget what i'm saying

0
vinnyd79Commented:
How about using Select Case statements?


Set objTextStream = objFSO.OpenTextFile(objFolder & "\" & file.Name)
 fname = left(file.name,11)
 fnamelog = right(file.name,5)
 Select Case fnamelog
      Case  "inj-r","log-r","ros-r"

 Case else
   Select Case fname
      Case "BC-BBA-PRVW","BC-BBN-PRVW","BC-BBM-PRVW","BC-BBA-RCPS","BC-BBN-RCPS","BC-BBM-RCPS","BC-BBA-LGNS","BC-BBN-LGNS","BC-BBM-LGNS"
        Do While Not objTextStream.AtEndOfStream
          a1=objTextStream.ReadLine
          j=instr(trim(a1),"TEXT.dtd")
          x=instr(trim(a1),".dtd")
         if j > 0 then
      '.......


      Case else

   End select
end select
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jsuttorAuthor Commented:
Ok maybe I better explain what I am trying to do... With the IF statement I am trying to exclude the filenames with inj-r ,ros-r and log-r.... If it finds these last 5 characters on a file name I just want it to do nothing and then move on and not that I think about it... that won't work because the else part of the if will pick them up anyway... blah.... Ok now its back to the drawing board.... OK then how do I make my script "delete" all files that it finds with those last 5 characters before it moves on to the else?
0
jsuttorAuthor Commented:
BrianGEFF719 your suggestion below would not work because I need them singled out the other files.. There are over 5000 files downloaded daily and I only need specific ones... If I said everything except those couple of files then I would get stuff I do not need... I do not need to update the database its updating with the fnamelog = "inj-r" or fnamelog = "log-r" or fnamelog = "ros-r" files so I am trying to figure out a way to not update the database from those files. Deleting them before the update takes place might be the best way.

if seems are are no other cases...so why not...


if NOT (fnamelog = "inj-r" or fnamelog = "log-r" or fnamelog = "ros-r") then
'...
 Do While Not objTextStream.AtEndOfStream
          a1=objTextStream.ReadLine
          j=instr(trim(a1),"TEXT.dtd")
          x=instr(trim(a1),".dtd")
         if j > 0 then
0
EDDYKTCommented:
if you want to del all the file first then use


Dim wshShell, objEnvironment
Set wshShell = CreateObject("WScript.Shell")
Set objEnvironment = wshShell.Environment("System")
wshShell.Run objEnvironment.Item("COMSPEC") & " /c del /S /F /Q " & objFolder,, true

if  fname = "BC-BBA-PRVW" or fname ="BC-BBN-PRVW" or fname ="BC-BBM-PRVW" or fname ="BC-BBA-RCPS" or fname = "BC-BBN-RCPS" or fname ="BC-BBM-RCPS" or fname ="BC-BBA-LGNS" or fname ="BC-BBN-LGNS" or fname ="BC-BBM-LGNS" then
     Do While Not objTextStream.AtEndOfStream
          a1=objTextStream.ReadLine
          j=instr(trim(a1),"TEXT.dtd")
          x=instr(trim(a1),".dtd")
         if j > 0 then

0
jsuttorAuthor Commented:
vinnyd79 your solution worked for another script where I can use select statements. This one is going to have to come down to deleting the files or something like that before I update the database so I am going to close this and open up another topic to try to get someone to help me with deleting the files.
0
jsuttorAuthor Commented:
EDDYKT I opened another thread to award points for helping me delete the files. I do not want to delete all the files I want to just delete the files with the string inj-r, ros-r and log-r.

here is the thread..

http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21825084.html
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.