Solved

How do you write a simple program in Visual Basic 2010

Posted on 2013-01-01
3
520 Views
Last Modified: 2013-01-02
I have Microsoft visual Studios 2010.I am trying to write something very simple in it just to get my "feet wet.".I would like to have a box that has the text "what is your name.".
Next to this box, I would like another box where I can type my name.I would then like to have a button at the bottom that says "OK".Then, when I click the okay button-it will say "hello Dan,"-or whatever name. I typed in the 2nd box.I don't know where the items I'm looking for are.
0
Comment
Question by:dwcronin
3 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
This should get you started

http://www.youtube.com/watch?v=fWmObdrbCMU
0
 
LVL 9

Expert Comment

by:sognoct
Comment Utility
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
Comment Utility
From the ToolBox...
Place a Label (Label1) onto the Form and change its Text Property to "What is your name:".
Place a TextBox (TextBox1) to the right of the Label.
Place a Button (Button1) to the right of the TextBox and change its Text Property to "OK".

Now Double Click on the Button to get the handler stub:
Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

    End Sub

End Class

Open in new window


Next, retrieve the value from TextBox1 using its Text Property and concatenate that with your message.  Store that in a String variable and display it with MessageBox.Show();
Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim msg As String = "Hello " & TextBox1.Text & "!"
        MessageBox.Show(msg, "Greeting", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

End Class

Open in new window

0

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

763 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

7 Experts available now in Live!

Get 1:1 Help Now