Trim Function

C

cmdolcet69

I ahve the following code that need to trim off the last character
from a string

dim STR as string
If instr(STR <3 then
LTrim(STR)


THis code doesn;t work
 
C

Clive Lumb

cmdolcet69 said:
I ahve the following code that need to trim off the last character
from a string

dim STR as string
If instr(STR <3 then
LTrim(STR)


THis code doesn;t work

1 - STR is a reserved name, use mySTR for example
2 - The line instr(STR <3 is incomplete and meaningless
3 - "Ltrim" just removes leading spaces
4 - It looks like you might be using VB6, is this the case?
 
A

ats@jbex

I ahve the following code that need to trim off the last character
from a string

dim STR as string
If instr(STR <3 then
LTrim(STR)


THis code doesn;t work

I think the TRIM() function only gets rid of whitespace. Try the LEFT$()
function:

dim STR as string
STR= "STRING"
STR = LEFT$(STR,3)

HTH
--
ats@jbex

Boats an' tanks and planes, it's your game
Kings an' queens an' generals learn your name
I see all the innocents, the human sacrifice
And if death comes so cheap
Then the same goes for life!

The Clash - Tommy Gun
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top