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

x
?
Solved

Remove Bracket and Its Value.

Posted on 2009-04-07
8
Medium Priority
?
181 Views
Last Modified: 2012-05-06
Hi,

I want to Remove Bracket and Its Value.

I have 3 functions to do it.

Public Shared Function Remove_Bracket_And_Its_Value(ByVal strData As String) As String

        Dim strValue As String = ERV_Global.Get_Value_Inside_Bracket(strData)

        strData = Replace(strData, strValue, "")

        strData = Remove_Bracket(strData)

        Return strData

    End Function

Could we make it simple the above function?

Thank you.

Public Shared Function Get_Value_Inside_Bracket(ByVal strData As String) As String
 
        If strData.Trim = "" Then Return ""
 
        Dim sep() As Char = New Char() {"(", ")"}
        Dim result() As String = strData.Split(sep)
 
        Return result(1)
 
    End Function
 
 
 Public Shared Function Remove_Bracket(ByVal strData As String) As String
 
        strData = Replace(strData, ")", "")
        strData = Replace(strData, "(", "")
 
        Return strData
 
    End Function

Open in new window

0
Comment
Question by:emi_sastra
[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
  • 4
8 Comments
 
LVL 48

Expert Comment

by:jpaulino
ID: 24090759
Maybe this way
    Public Shared Function Remove_Bracket(ByVal strData As String) As String
        Return strData.Replace(")", "").Replace("(", "")
    End Function

Open in new window

0
 
LVL 1

Author Comment

by:emi_sastra
ID: 24090805
Hi jpaulino,

My main target is below function:

Public Shared Function Get_Value_Inside_Bracket(ByVal strData As String) As String
 
        If strData.Trim = "" Then Return ""
 
        Dim sep() As Char = New Char() {"(", ")"}
        Dim result() As String = strData.Split(sep)
 
        Return result(1)
 
    End Function


ie.  CustCode (Char(6)) ----> CustCode

Thank you.


0
 
LVL 1

Author Comment

by:emi_sastra
ID: 24090814
Sorry,

I mean below function:

Public Shared Function Remove_Bracket_And_Its_Value(ByVal strData As String) As String

        Dim strValue As String = ERV_Global.Get_Value_Inside_Bracket(strData)

        strData = Replace(strData, strValue, "")

        strData = Remove_Bracket(strData)

        Return strData

    End Function

ie.  CustCode (Char(6)) ----> CustCode

Thank you.
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 48

Expert Comment

by:jpaulino
ID: 24090905
You have this "CustCode (Char(6))" and you want to return what ?
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 24090929
You have this "CustCode (Char(6))" and you want to return what ?
To "CustCode"

Or "(aaaa) CustCode (Char(6))"  To CustCode.
Remove anything inside bracket and its bracket.

Thank you.
0
 
LVL 48

Accepted Solution

by:
jpaulino earned 2000 total points
ID: 24091055
Try this way
    Public Shared Function Remove_Bracket_And_Its_Value(ByVal strData As String) As String
        Dim posStart As Integer = strData.IndexOf("("c)
        Dim posEnd As Integer = strData.IndexOf(")"c)
 
        While (posStart <> -1 AndAlso posEnd <> -1)
            strData = strData.Remove(posStart, posEnd - posStart + 1)
            posStart = strData.IndexOf("("c, posStart)
            If posStart <> -1 Then
                posEnd = strData.IndexOf(")"c, posStart)
            Else
                posEnd = strData.IndexOf(")"c)
            End If
 
        End While
 
        Return strData.Replace("(", "").Replace(")", "")
    End Function

Open in new window

0
 
LVL 1

Author Comment

by:emi_sastra
ID: 24091128
It works.

Thank you very much for your help.
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24091194
Glad I could help!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

636 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