Solved

ASP.NET/VB: Trim quotation marks from beginning and end

Posted on 2011-09-06
7
484 Views
Last Modified: 2012-05-12
Using ASP.NET/VB, I would like to trim quotation marks from the beginning and end.

These charactors should be REMOVED if they are the first or last character of the Headline.

"“”
<h2><%#Container.DataItem("Headline")%></h2>

Open in new window

0
Comment
Question by:hankknight
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 28

Accepted Solution

by:
strickdd earned 500 total points
ID: 36490709
code infront:

 <h2><% FormatTitle(Container.DataItem("Headline"))%></h2>

code behind:

protected function FormatTitle(title As Object) As String
    Dim temp as String
    Dim originalString As String = title.ToString()

    if originalString.StartsWith(""") then
        temp = originalString.SubString(1)
    else
        temp = originalString
    end if

     if temp.EndsWith(""") then
         temp = temp.SubString(0, temp.Length - 1)
    end if

   return temp

end fuction
0
 
LVL 16

Expert Comment

by:disrupt
ID: 36490942
0
 
LVL 16

Author Comment

by:hankknight
ID: 36490980
Thanks.  disrupt, this needs to be VB not C#.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:disrupt
ID: 36490981
"TrimStart and TrimEnd are supposed to take a character array as a parameter. If you type the keyword null instead, it will trim the white space (blank characters)."

you can also just do this:

returnValue.TrimStart( '" ', '“','”' );
returnValue.TrimEnd( '" ', '“','”' );
0
 
LVL 16

Expert Comment

by:disrupt
ID: 36490993
It will work in vb .net fine just leave out the semicolon at the end :)
0
 
LVL 16

Expert Comment

by:disrupt
ID: 36491007
0
 
LVL 16

Author Comment

by:hankknight
ID: 36491145
Thanks, disrupt.   I awarded the points just moments before you made your post.

strickdd, you solution works.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.Net - String Manipulation Scenario 2 31
ASP.NET MVC - Views 3 43
Cannot kill Excel from taskmgr after Excel Export in VB 2014 6 39
VB.net VSTO Excel Ribbon error 4 14
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

726 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