?
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
Medium Priority
?
586 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 400 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

Technology Partners: 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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month13 days, 22 hours left to enroll

801 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