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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading last 3 characters 1

Status
Not open for further replies.

Aeros

Programmer
Oct 7, 2002
166
US
Im pulling a string out of a dabase and need to read the last three characters. Whats the best way of doing this?

Thanks
 
Actually what im pulling out is a filename and would like to read the extention..so whatever is after the period.

Thanks
 
listLast(queryName.columnName, ".")

If you don't ask the right questions, you don't get the right answers. A question asked in the right way often points to its own answer. Asking questions is the ABC of diagnosis. Only the inquiring mind solves problems.

-Quote by Edward Hodnett
 
An all-purpose methos would be like this, if you ever need it for a 'non-list-able' string

mid(string,len(string)-2,len(string))

where 2 is the length-1 that you need displayed (since it is the starting point, and is counted as 1).

 
the problem in this case is the starting point. Yeah you could get to it but listlast is still the easiest way. also the length you need displayed in this case may also differ.


for example
my.image.from.home.jpeg

is a valid windows file name and jpeg is 4 characters, you'd have to use find() and get the last "." for it to work right.

If you don't ask the right questions, you don't get the right answers. A question asked in the right way often points to its own answer. Asking questions is the ABC of diagnosis. Only the inquiring mind solves problems.

-Quote by Edward Hodnett
 
You're exactly right.

"Im pulling a string out of a dabase and need to read the last three characters."

Is all I was answering. Your way is the best way for this case.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top