Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 300,089 times

Contents

Related Categories

Visual Basic Tutorial - User Input

User Input

As we have now written some text asking the user (the person using the program) for his or her name, we need to give them somewhere to type it. To do this we use the TextBox control. This is the icon in the Toolbox. Just like before, select this icon, and add the textbox to your form, next to the 'Please enter your name' text. Again, we can use the Properties window to change a few things. First, rename the textbox to txtName (as txt is the conventional prefix for textboxes). The other thing we need to change is its Text property; because the user needs to enter some text, the textbox needs to start out empty, rather than having 'Text1' displayed in it. To do this, scroll down to the Text property in the Property Window, and delete the text.

By now, your form should look something like this:

For the next stage you need to add one more control; the CommandButton control. This simply a button that the user can click, in this case to say that he/she has entered their name. To add the control, click the icon, and add the control to your form, next to the text box. Name this control cmdOK, and set its Caption property to 'OK'.

You will notice that to change the text on a control, sometimes the property is called Caption, and sometimes it is called Text. The reason for this is that in a Text box, a user can change what appears in it (and therefore it is Text). On a button or label control however, the text is static. This means that it cannot be changed by the user.

James first started writing tutorials on Visual Basic in 1999 whilst starting this website (then known as VB Web). Since then, the site has grown rapidly, and James has written numerous tutorials, articles and reviews on VB, PHP, ASP and C#. In October 2003, James formed the company Developer Fusion Ltd, which owns this website, and also offers various development services. In his spare time, he's a 3rd year undergraduate studying Computer Science in the UK. He's also a Visual Basic MVP.

Comments

  • Re: [30] Complete VB Beginners Tutorial

    Posted by pcmenegusso on 06 Jun 2008

    what's "grammer" anyway? and who's needing it here?

  • Re: beginner...

    Posted by HartTechService on 27 May 2008

    No offense, but you might want to brush up on your English grammer skills first.  "We'll gonna"= We will gonna or going too??????  This just makes no sense.  "We are ...

  • beginner...

    Posted by Tessa07 on 13 Jun 2007

    Hi evry1..
    I take IT course, n we'll gonna use VB for nxt semester.1st n 2nd semester we already have C n C++,so  i hope any1 here can help me out..TQVM..

  • New to VB.net

    Posted by asingh9 on 08 Sep 2005

    Hi,
    I have been using Visual Basic for one year. Now, I want to switch to VB.net as it is the latest technology. I am totally confused how should I go about doing this. Could you tell me the name of ...

  • Student edition

    Posted by eric2358 on 10 Aug 2005

    You may not be able to comile your code into an executable that would be portable, but your code can be copied into notepad files and kept for later use/reuse.