Solved

Vbscript : I want to remove a quote at the beginning of a string an one at the end of a string

Posted on 2011-03-02
3
348 Views
Last Modified: 2012-05-11
How can I achieve this ?
0
Comment
Question by:itbabe
3 Comments
 
LVL 12

Accepted Solution

by:
prashanthd earned 167 total points
ID: 35019194
can you give an example of the string?

You can try the following

str=Chr(34) & "This is a quote" &chr(34)

WScript.Echo Replace(str,Chr(34),"")
0
 
LVL 51

Assisted Solution

by:Bill Prew
Bill Prew earned 167 total points
ID: 35020663
Something like this will work:

'Strip single quote from left of string
If Left(str,1) = "'" Then
  str = Right(str, Len(str)-1)
End If
'Strip single quote from right of string
If Right(str,1) = "'" Then
  str = Left(str, Len(str)-1)
End If

Open in new window

~bp
0
 
LVL 65

Assisted Solution

by:RobSampson
RobSampson earned 166 total points
ID: 35022436
Bill is right.  That's for a single quote, if you wanted to remove a double quote, use

strText = """My Text"""
If Left(strText, 1) = """" Then strText = Mid(strText, 2)
If Right(strText, 1) = """" Then strText = Left(strText, Len(strText) - 1)

Open in new window


Regards,

Rob.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now