Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


A problem

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,59799
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> A problem
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 A problem - 5/4/2008 9:02:24 PM   
  wmec

 

Posts: 125
Score: 0
Joined: 8/5/2004
From: Hong Kong, China
Status: offline
Hi,
I have defined both of these and have a problem with the conditions (it says "Invalid procedure call or argument"). Any advice?

...
           te_str = UCase(Trim(Cells(rw, 2).Value))
           te_str2 = Trim(Cells(rw, 3).Value)
          
           If Asc(Mid(te_str, 1, 1)) >= 65 _
               And Asc(Mid(te_str, 1, 1)) <= 90 _
               And Mid(te_str, 2, 1) = "." _
               And Len(te_str) = 2 _
               And Not IsNull(te_str2) Then
...

_____________________________

Thanks & Best Regards,

HuaMin Chen
 
 
Post #: 1
 
 RE: A problem - 5/4/2008 11:01:07 PM   
  ehvbs

 

Posts: 2037
Score: 48
Joined: 6/22/2005
From: Germany
Status: offline
Hi wmec,

other programming lanuages like C do a 'lazy'/'shortcut' evaluation of the
boolean expression in an if statement: As soon as the boolean value of
the whole expression is determined, no further evaluation of the leftmost
sub expression is done. That's why in C something like this

if( pString && *pString && doSomethingWithADecentString( pString ) )

works. VBScript evaluates all parts of a compley boolean expression to
compute the value of the whole. That is why

IF ... Asc( Mid( sShort, 2, 1 ) ) ... Then

will fail, if sShort is 'bad' - no matter if or where you put guarding
tests into the expression. You'll have to nest your tests, as in this
demo:


      

output:


      

Good luck - with the feazing of your expressions!

ehvbs

(in reply to wmec)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> A problem Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts