Visual Basic

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsDesktop ProgrammingVisual Basic

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old August 20th, 2010, 11:59 PM
vbboard vbboard is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Aug 2010
Posts: 5 vbboard User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 28 m 19 sec
Reputation Power: 0
[TUT] Hello User [Easy]

Originally on my site: http://vb-board.com


Most people are used to the basic one button click "Hello World" tutorial. But today I am going to show you the little bit more advanced version called "Hello User"

First open up Visual Basic, I use the 2010 Express version which you can download at http://www.microsoft.com/express/downloads/

Go to File > New Project > Windows Forms Application and at the bottom name it "Hello User"

You should now have a blank "Form1" application. Click the grey area and in the bottom right corner you should see the properties box. Scroll to the text property and change it to what ever you want, probably "Hello User". Press enter and you will see the name of your form has changed, that is what the text property does.

Now, add a label control to your form from the toolbox.
Note: If you can't see the toolbox click Ctrl+Alt+X
Click the label and change the text property to "Enter your name"

Add a textbox control and move it under the label. This is where the user will enter their name into. Change the "Name" property to txtName.
Note: The name property is used to reference to the control in your code.

Add two button controls
1. Change the text property to "Ok" and the name property to "btnOk"
2.Change the text property to "Exit" and the name property to "btnExit"

Double click the Ok button and add the bolded code.
Code:
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
        'displays a message box greeting to the user
        MessageBox.Show("Hello, " & txtName.Text & "! Welcome to VB 2010")
    End Sub


Messagebox.show = Pops up a message box with whatever is in the parenthesis.
("Hello, " & txtName.Text & "! Welcome to VB 2010") = Will show as exactly what it says. txtName.text will get the text from your textbox control.
Ampersands(&) = connect what is in between the quotation marks and your code. There must be a blank space preceding it.

Return to your Design editor and double click the exit button
Once again, add the bolded code


Code:
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub

Me = tells the program it will act upon itself
close = obviously close

Now go to File > Save All and browse to the folder you want to save it to. Then hit "F5" or the green button that says start debugging to start your program. Type a name and hit "ok" and tada, you get a lovely greeting to visual basic 2010. Now hit exit and it closes. If you want to get an exe file for your program go to Debug > Build. This will build it into the same place you saved it. It will be found in Bin > Release > Program.exe

Enjoy Everyone,
Zer[o]

Reply With Quote
Reply

Viewing: Tutorialized ForumsDesktop ProgrammingVisual Basic > [TUT] Hello User [Easy]


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap