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
585 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

696 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