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
582 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

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 …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

785 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