Solved

Truncate or instring function for cutting the value and taking only part of value from my form value

Posted on 2006-06-21
3
580 Views
Last Modified: 2010-08-05
Hi Experts,
I have values comming from my form as Station 1, station 2, Station 3, Station 4, Station 5, Upto 13 As strings. I need to get only last part of station. Ie station Number, 1, 2,3,4,5,6,7,8,9,10 etc..

For example = Value = 13

Which Function should I use it.Is it instring ot truncate
Please advice

Palilu
0
Comment
Question by:pallilu
3 Comments
 
LVL 4

Expert Comment

by:indu_mk
ID: 16952958
Dim str As String
str = "Station 13"
Dim i As Integer
i = str.LastIndexOf(" ")
Value = str.Substring(i)
0
 

Author Comment

by:pallilu
ID: 16953384
Indu
Thanks for your response
I am getting space and number For example - value = 11

How to get rid of space

I have form value always Station 1, Station 2 Always Station name space and Number.

Please advice
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 100 total points
ID: 16953641
Try this regular expression:

Imports System.Text.RegularExpressions

Public Class RegexParser

  Public Shared Function ExtractNumber(ByVal input As String) As String

    Dim pattern As String = "\d+"

    Dim match As Match = Regex.Match(input, pattern)

    If match.Success Then
       Return match.Value
    End If

    Return ""

  End Function

End Class

Example usage:
  Dim number As String = RegexParser.ExtractNumber("Value = 13")

Bob
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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 …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 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

21 Experts available now in Live!

Get 1:1 Help Now