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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

747 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

13 Experts available now in Live!

Get 1:1 Help Now