|
-
May 21st, 2007, 07:44 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Commas
Say i have this in a textbox..
a b c d e
how do i have a commandbutton that will replace this into:
a, b, c, d, e
please keep in mind that there MAY be a space at the end of the e, or at the beginning of the a. also keep in mind i do NOT want it to show as ,a b, c, d, e, .... i want it as a, b, c, d, e .. how do i do this?
Thanks!!!!
Last edited by Hack; May 22nd, 2007 at 06:14 AM.
Reason: Added RESOLVED to thread title and green resolved checkmark
"Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."
-
May 21st, 2007, 07:47 PM
#2
Re: Commas
Try using Replace() function:
Code:
Debug.Print Replace("a b c d e", " ", ", ")
-
May 21st, 2007, 07:54 PM
#3
Thread Starter
Hyperactive Member
Re: Commas
Works great, but, like i said, there could be a space on the end of the e. Then, if i use your code and put a space at the end of the e, i get a comma at the end regardless of there being text or not at the end.
"Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."
-
May 21st, 2007, 08:08 PM
#4
Re: Commas
So, check for last two characters and if you get ", " the use Left function:
Code:
mystring = "a b c d e "
mystring = Replace(mystring, " ", ", ")
If Right(mystring, 2) = ", " Then
mystring = Left(mystring, Len(mystring) - 2)
End If
-
May 21st, 2007, 08:09 PM
#5
Thread Starter
Hyperactive Member
"Remember, remember the 5th of November, the gun powder treason and plot. I know of no reason why the gun powder treason should ever be forgot."
-
May 22nd, 2007, 12:55 AM
#6
Re: Commas
Now that we've helped you, you can help us by pulling down the Thread Tools menu and clicking the Mark Thread Resolved button which will let everyone know that you have your answer. Also if someone has been particularly helpful, or even particularly unhelpful, you have the ability to affect a their forum "reputation" by rating their post..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|