Solved

Get Value Inside Bracket

Posted on 2009-04-06
4
277 Views
Last Modified: 2012-05-06
Hi,

I want to get value inside bracket.

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

Is there a simple way to do it than using instr function ?

Thank you.
0
Comment
Question by:emi_sastra
  • 2
4 Comments
 
LVL 48

Accepted Solution

by:
jpaulino earned 250 total points
ID: 24075546
Here's a way
        Dim str As String = "Char(6)"
        Dim sep() As Char = New Char() {"(", ")"}
        Dim result() As String = str.Split(sep)
 
        MessageBox.Show(result(1))

Open in new window

0
 
LVL 47

Assisted Solution

by:Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs) earned 250 total points
ID: 24075551
The easiest method is to use Regular Expressions....
        Dim s As String = "VarChar(6)"
        Dim regex As New System.Text.RegularExpressions.Regex("\((\d+)\)")
        Dim num As Integer = Convert.ToInt32(regex.Match(s).Groups(1).Value)

Open in new window

0
 
LVL 1

Author Comment

by:emi_sastra
ID: 24075610
Hi All,

Let me try first.

Thank you.
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 24075654
Hi All,

It all works.

Thank you very much for your help.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

808 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