Solved

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

Posted on 2011-09-06
7
479 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
  • 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
convert html to string 6 34
C#, asp.net MVC, sql server, LINQ 3 31
rebind a grid after user clicks on node in treeview 1 34
List<PaisEntity> - show some 1 24
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
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…

813 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

14 Experts available now in Live!

Get 1:1 Help Now