Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2006

Tip: Looking for answers? Try searching our database.

Cropping a String

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrew - 14 Nov 2006 18:18 GMT
I am looking to crop a String based on a "/".  I want to crop out everything to the right of the "/" as well as the " " that is to the left of it.  I ultimately want only that which is to left of " /".

As always your help is greatly appriciated.

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
Greg Maxey - 14 Nov 2006 18:45 GMT
Not sure I copy what it is that you are seeking (you want to crop out
everything to the right of ... as well as everything to the left of).
Whouldn't that leave you with /?

Do you mean you want to keep everything to the left?  If so, perhaps:

Sub Scratchmacro()
Dim pStr As String
Dim i As Long
pStr = "Day 7 of a / new dark age"
MsgBox Left(pStr, InStr(pStr, "/"))
End Sub

> I am looking to crop a String based on a "/".  I want to crop out everything to the right of the "/" as well as the " " that is to the left of it.  I ultimately want only that which is to left of " /".
>
> As always your help is greatly appriciated.
>
> EggHeadCafe.com - .NET Developer Portal of Choice
> http://www.eggheadcafe.com
Andrew V - 14 Nov 2006 21:16 GMT
myStr = "before / after"
'value of myStr is "before / after"

myStr = Split(myStr," /")(0)
'value of myStr is "before"

Andrew V

> I am looking to crop a String based on a "/".  I want to crop out everything to the right of the "/" as well as the " " that is to the left of it.  I ultimately want only that which is to left of " /".
>
> As always your help is greatly appriciated.
>
> EggHeadCafe.com - .NET Developer Portal of Choice
> http://www.eggheadcafe.com
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.