is it possible for this piece of code to be amended to include more than one
type of file extension?
If sExt = "jpg" or "jpeg"
doesn't seem to work.


sExt = oFSO.GetExtensionName(oFile)
If sExt = "jpg"

Re: If sExt = "jpg" or "jpeg" by Michael

Michael
Fri Oct 29 22:23:10 CDT 2004

fitful_thought wrote:
> is it possible for this piece of code to be amended to include more
> than one type of file extension?
> If sExt = "jpg" or "jpeg"
> doesn't seem to work.
>
>
> sExt = oFSO.GetExtensionName(oFile)
> If sExt = "jpg"

WSH 5.6 documentation download
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en

Microsoft® Windows®2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp


sExt = LCase(oFSO.GetExtensionName(oFile))
If sExt = "jpg" Or sExt = "jpeg" Then
...
Else
... default
ElseIf sExt = ... Or sExt = ...
... default
End If

or...

sExt = LCase(oFSO.GetExtensionName(oFile))
Select Case sExt
Case "jpg", "jpeg"
...
Case ...
...
Case Else
... default
End Select

--
Michael Harris
Microsoft.MVP.Scripting

TechNet Script Center Sample Scripts
http://www.microsoft.com/technet/scriptcenter/default.asp
Download in HTML Help format (searchable)
http://www.microsoft.com/downloads/release.asp?ReleaseID=38942



Re: If sExt = "jpg" or "jpeg" by fitful_thought

fitful_thought
Sat Oct 30 02:49:29 CDT 2004

Malcolm,

Thank very much for that.

That not only helps solve my programming problem with an elegant solution,
but also it enables me to understand more about the VB syntax.

"Malcolm K Smith" <mksmith@cix.compulink.co.uk> wrote in message
news:memo.20041030084218.3388C@mksmith.aits-uk.net...
> Dear Mr Fitful of Thought
>
> How any if statement works in any of these languages is that the If part
> is entered if the statement can be said to be True.
>
> In other words the whole thing always boils down to:
>
> If True then
> ' Do stuff
> end if
>
> So, what we have in the If statement is a set of statements which must
> boil down to a Boolean true.
>
> So, to put it into English one could write:
>
> "Is it true that the variable called 'eExt' has the value 'jpg'?"
>
> for the code:
>
> if sExt = "jpg" then
>
> Now in your code what you have done is to write the following:
>
> "Is it true that the variable called 'eExt' has the value 'jpg' OR
> that the string "jpeg" is True?"
>
> Clearly the latter part of the clause is meaningless and can't even
> interpret so it fails.
>
> What you should have written is:
>
> "Is it true that the variable called 'eExt' has the value 'jpg' OR that
> the variable called 'eExt' has the value 'jpeg'?"
>
> Which would translate to:
>
> If (sExt="jpg") or (sExt="jpeg") then
>
> I have added the brackets for clarification.
>
> Now of either of these statements is True then by our knowledge of Boolean
> arithmetic that True or False always returns True then the If statement is
> true and so the bit in the If statement is entered.
>
> So if sExt did contain "jpg" then the above If statement would look like
> this when interpreted:
>
> If TRUE or FALSE then
>
>
> If eExt contained, say, "gif" then the statement would be resolved like
> this:
>
> If FALSE or FALSE then
>
> and the control which skip over the if/end if part.
>
>
> It is always useful to think in this way until one has got a grip with the
> If statements.
>
>
> * AN ASIDE*
>
> Now, a tip when writing VB (a typed language) one therefore needn't write
> for example:
>
> Dim bIsRaining as Boolean
>
> ' Lots of code here
>
> If bIsRaining = True then
>
> This is redundant because the If statement always breaks down the clauses
> into Boolean statements, so writing:
>
> If bIsRainging then
>
> is more consise and does exactly the same job because bIsRaining is a
> Boolean variable and, thus, resolves to a Boolean result because it is
> one.
>
>
> Anyway, does this ramble help?
>
> - Malc
> www.dragondrop.com
>
>
>
>
>