Solved

Get Value Inside Bracket

Posted on 2009-04-06
4
276 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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

831 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