Solved

how to remove a hyphen from a string in vb.net?

Posted on 2013-05-22
2
589 Views
Last Modified: 2013-05-22
Hello,

I have a string like At --- 153 and i need to get rid of this hyphens(---) and get the string as
AT 153,  How Can I achieve this in vb.net ? Thanks!
0
Comment
Question by:developer2012
[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
2 Comments
 
LVL 23

Assisted Solution

by:tailoreddigital
tailoreddigital earned 250 total points
ID: 39189272
http://www.dotnetperls.com/replace-vbnet


Based on their example you could,

Module Module1
    Sub Main()
      ' Assign string to reference.
      Dim value1 As String = "At --- 153"
      Console.WriteLine(value1)

      ' Replace word with another word.
      Dim value2 As String = value1.Replace("---", "")
      Console.WriteLine(value2)
    End Sub
End Module
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 250 total points
ID: 39189341
Another way...this splits on both space and hyphen, then re-joins it back together so that you end up with just one space in the end:
        Dim str As String = "At --- 153"
        str = String.Join(" ", str.Split("- ".ToCharArray, StringSplitOptions.RemoveEmptyEntries))
        Debug.Print(str)

Open in new window

0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

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