Invalid Procedure Call or Argument (1 Viewer)

pooldead

Registered User.
Local time
Today, 13:40
Joined
Sep 4, 2019
Messages
107
I'm getting the error "Invalid Procedure Call or Argument" with the following piece of code:
Code:
replaceLDAP = Right(strRole, (Len(strRole) - 9))
I've done some research and tried adding in a check to ensure "strRole" > 0, which I also manually confirmed, but no dice. I have been able to figure out it seems to occur when I include the "- 9". My goal with this is to remove the first 9 characters from the strRole string.
 

The_Doc_Man

Immoderate Moderator, Former MVP, Retired SysAdmin
Staff member
Local time
Today, 15:40
Joined
Feb 28, 2001
Messages
18,299
The fastest way to understand what is going on is to put a breakpoint on that line, which means the break occurs BEFORE you execute anything.

Then hover the mouse over strRole to see what it contains. If less than 9 characters, it was the negative number in the length argument that ate your socks for you.
 

plog

Banishment Pending
Local time
Today, 15:40
Joined
May 11, 2011
Messages
10,125
My goal with this is to remove the first 9 characters from the strRole string.

And if strRole has less than 9 characters?

Testing for >0 doesn't help if you are subtracting 9 from its length and its length is less than 9. Your test needs to accomodate that subtraction.
 

pooldead

Registered User.
Local time
Today, 13:40
Joined
Sep 4, 2019
Messages
107
Thank you everyone. There are a number of good ideas in here to try and/or consider. I'll give them a go in the morning and post an update.
 

Users who are viewing this thread

Top Bottom