Solved

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

Posted on 2013-05-22
2
565 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
2 Comments
 
LVL 23

Assisted Solution

by:tailoreddigital
tailoreddigital earned 250 total points
Comment Utility
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 85

Accepted Solution

by:
Mike Tomlinson earned 250 total points
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

771 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

10 Experts available now in Live!

Get 1:1 Help Now