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!

Trim Char at the end 1

Status
Not open for further replies.

PhatH

IS-IT--Management
Mar 30, 2004
88
US
Hello

I want to Trim a comma at the end of a string

strProdTid = rs1("ProdTypeID")
instr(strProdTid, ",") then
arrNums = Split(strProdTid, ", ", -1, 1)
strName = ""

For Each strOneNum in arrNums
sql = "SELECT ProdTypeName FROM tblProductType WHERE ProdTypeID = " & strOneNum
Set rs5 = objConn.Execute(sql)
strName = rs5("ProdTypeName") + ", " + strName
Next

OUTPUT= test1, test2, test3,
^
---------------------------|
This comma the one to go.

Thanks
 
:) Nevermind the drawing on the bottom... It's just want to point at the last comma of the sentence...
 
left(string,len(string)-1)

Chris.

Indifference will be the downfall of mankind, but who cares?
 
Thank ChrisHirst for your help
...
strName = rs5("ProdTypeName") + ", " + strName
Next
strName = left(strName,len(strName)-1)

I added your code like this, but nothing has changed, could you tell what I missed.
 
is there a space after the comma in the quotes? if so either use -2 or

left(strName,len(trim(strName))-1)



Chris.

Indifference will be the downfall of mankind, but who cares?
 
Thank again ChrisHirst... instead of -1, -2 will do the job. :)
 
how about reverse() to make it the first comma

___________________________________________________________________

The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page faq333-3811
 
Reverse() is not working for my case. Maybe I didn't use it right. Thank onpnt anyway!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top