Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LEFT not working properly?

Status
Not open for further replies.

frosty7700

Programmer
Aug 10, 2001
95
US
I keep getting an "Invalid procedure call or argument: 'Left'" message when I run the following code:

company = replace(company,"'","''")
x = instr(company,"-") - 1
company = Left(company,x)

What's weird is when I remove the "- 1" from line 2, for example if I use "+ 1" or nothing at all, it works fine. I have verified that dashloc IS getting a numeric value regardless, so I'm really stumped...it's as if the LEFT function has just decided to take on an aversion to subtraction. Note that I have also tried:

company = replace(company,"'","''")
company = Left(company,instr(company,"-") - 1)

 
Left will not accept negative length. What if no "-"?
Never trust that Instr will always return > 0.
company = replace(company,"'","''")
x = instr(company,"-") - 1
if X < 1 then
company = &quot;&quot;
else
company = Left(company,x)
End if
Forms/Controls Resizing/Tabbing Control
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top