Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-05-22
2
Medium Priority
?
647 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 750 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 750 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

618 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