VB 2005:  How to select a digit from a number and assign it to a new variable?

Posted on 2008-11-11
Last Modified: 2013-11-26
Dear experts:


I would like to learn how to select a digit (5) from a   7-digit number like "2345678", and
assign the selected digit (5) to a new variable.

Thanks a lot!
Question by:duta
    LVL 8

    Expert Comment

    string Digit = TextBox1.Text.SubString(4,1)

    Please do check the SubString function. I don't remember it exactly.
    LVL 48

    Accepted Solution

    Just a VB change to rpkhare code

    Dim str As String = "2345678" 
    Dim digit As String = str.Substring(3, 1)

    Open in new window


    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.

    Join & Write a Comment

    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    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…

    754 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