C sharp / C# - simple code using a TextBox and 5 OutputBoxes

Posted on 2009-02-20
Last Modified: 2013-12-17
Hi everyone,

I am learning C sharp / C# and I am trying to do something very simple.  Here is the scenario:

1.  I have an input box, (TextBox1), an 'Enter' button, and five output boxes (OutputBox1 through OutputBox5)
2.  I want the user to enter '12345' into TextBox1 and click 'Enter'
3.  The result should split the text into the five output boxes as follows:
OutputBox1 = 1
OutputBox2 = 2
OutputBox3 = 3
OutputBox4 = 4
OutputBox5 = 5

This is simple- any help is appreciated.

Question by:morciani
    LVL 96

    Assisted Solution

    by:Bob Learned
    What have you tried, and how may I help you get where you need to be, without writing the code for you?
    LVL 17

    Accepted Solution

    I'm not going to help you in pure code but these lines of code can help you:
    string str;
    str = "ABCDEFG";
    MessageBox.Show(str.Substring(0, 1).ToString());

    and you should code it yourself...
    LVL 15

    Assisted Solution

    There are several options you can take.  Each depending on what your actual requirements are, to help you get started I will give you some idea of what you could do.  

    If your string is going to be constant (i.e. the user isn't going to change from 1,2,3,4,5) then you could create a switch case whereby if a character is equal to X, then TextBoxY is assigned value X.  Similar methods can be done via an if statement.  However both of these methods require you to split the string into characters, they would also mean hard-coding values which is never great.  

    Author Closing Comment

    Thanks for the help- I figured this one one after a little digging.  I apologize- I may have posted my question in a rush....

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    745 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

    15 Experts available now in Live!

    Get 1:1 Help Now