Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1381
  • Last Modified:

Replace last character in string if it is "\"

I have a form where the user can select a network directory.  I have a nice little browse button for them to use, but of course they can type it in as well.  I just need to check the string they type in and remove the last character if it is "\".  I tried:

Dim varFolderName As String
varFolderName = txtSharedFolder.Value, "\", "", Len(txtSharedFolder.Value) - 1)

But the value it returns is missing everything up to Len(txtSharedFolder.Value) - 1.  Which in retrospect makes sense.  Now I'm just drawing a blank on what to do.  If there is a way to search from right to left in the string I could use the count function.  Or maybe there is just a better way to approach it completely.  Any suggestions would be helpful.

Dave
0
magicspringsadmin
Asked:
magicspringsadmin
  • 3
1 Solution
 
Rey Obrero (Capricorn1)Commented:

you can use
If right("yourstring",1) ="\" then
0
 
Rey Obrero (Capricorn1)Commented:

if right("yourString",1)="\" then
     yourString=left("yourString",Len("yourString")-1)
end if
0
 
mbizupCommented:
Try this:

snew = iif(right(s,1) = "\", left(s,len(s)-1),s)
0
 
Rey Obrero (Capricorn1)Commented:
Dim varFolderName As String

if right(trim(me.txtSharedFolder,1))="\" then

varFolderName = left(trim(me.txtSharedFolder), Len(trim(me.txtSharedFolder)) - 1)

end if
0
 
magicspringsadminAuthor Commented:
Thank you for helping me with that mental block.

Dave
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now