.NET
  Home arrow .NET arrow Page 4 - Soup to Nuts Lab 1: A Tour of Visual Studi...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
.NET

Soup to Nuts Lab 1: A Tour of Visual Studio.Net
By: MSDN Virtual Labs
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 27
    2006-02-09

    Table of Contents:
  • Soup to Nuts Lab 1: A Tour of Visual Studio.Net
  • Exercise 1: Create a Simple Windows Forms Application
  • Exercise 2 Using the Visual Studio .NET IDE Tools
  • Exercise 3: Write Some Code
  • Exercise 4: Basic Debugging
  • Exercise 5: Configuring the Visual Studio .NET IDE

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Soup to Nuts Lab 1: A Tour of Visual Studio.Net - Exercise 3: Write Some Code


    (Page 4 of 6 )

    Scenario

    In this exercise, you will write a simple button-click event handler for the Get Customer button on the Customers form. You will declare some variables, concatenate strings and write code to display a message box.

            Tasks              Detailed Steps

    1. Create a button-click event.

      Note: C# is a case-sensitive language. If using C#, Ensure that the code you type matches the code in to the right exactly.

        1. Return to the Customers.xx [Design] tab. 
        2. In the forms designer, Double-click the button with the text Get Customer.

          The code pane opens and you see an event handler stub, ready for you to write some code into. 
        3. Write some code into the button click event handler to declare a string variable named Value, display a message in a message box, concatenate a value and assign it to the variable, then display the variable’s value in a message box:

          C#

            private void button1_Click(object sender,
               EventArgs e)
            {
               string Value = textBox1.Text; 
               MessageBox.Show("Hello, Soup to Nuts!");
               Value = "You typed " + Value;
               MessageBox.Show(Value);
            }

          Visual Basic .NET

            Private Sub Button1_Click(ByVal sender As Object, _  
               ByVal e As EventArgs) Handles Button1.Click
               Dim Value As string = TextBox1.Text 
               MessageBox.Show("Hello, Soup to Nuts!")
               Value = "You typed " & Value
               MessageBox.Show(Value)
          End Sub

    2. Create an application entry point.

        1. In the Solution Explorer, right-click Northwind, choose Add | Add Class.

          The Add New Item dialog displays with Class selected by default.

        2. In the Name box, clear the default text and type MainClass
        3. Click Open.

          The code pane opens for the new class in the center pane of the IDE.
           
        4. Add a Main sub routine MainClass class. The class should look like the following:

          C#
          using System;
          namespace Northwind
          {
            /// <summary>
            /// Summary description for MainClass.
            /// </summary>
            public class MainClass
            {
              public MainClass() 
              {
                //
                // TODO: Add constructor logic here
                //
            }
            public static void Main(string[] args)    
            {
              System.Windows.Forms. Application.Run(
                new Customers());
            }

          }


          Visual Basic .NET
          Public Class MainClass 
            Public Shared Sub Main(ByVal args as string())  
              System.Windows.Forms. Application.Run( _
                New Customers())
            End Sub
          End Class

    3. Change the application entry point to be the one you just created.

        1. Delete the default Form1.

          C#

          In Solution Explorer, right-click Form1.cs and choose Delete, then click OK.

          Visual Basic.NET

          In Solution Explorer, right-click Form1.vb and choose Delete, then click OK.

          Visual Basic.NET Only
        2. In Solution Explorer right-click the Northwind project node and choose Properties.
        3. Change the Startup object in the Northwind Property Pages dialog, under Common Properties->General, in the Startup object: dropdown, choose Sub Main
        4. Click OK.

    Take Microsoft software for a test drive. With MSDN Virtual Labs, you get full access to all available Microsoft products through 90-minute modules, each with its own downloadable manual. Try this lab out now.

    More .NET Articles
    More By MSDN Virtual Labs


       · We hope you found this article from MSDN Virtual Labs to be both educational and...
     

    .NET ARTICLES

    - Using CrystalReportViewer to Display Crystal...
    - Creating Summary .Net Crystal Reports
    - More on Commands, Input and the WPF
    - Grouping and Aggregating When Querying LINQ ...
    - Commands, Input and the WPF
    - Keyboard and Ink Input with WPF
    - Mouse Input and the WPF
    - Input with Windows Presentation Foundation
    - Introducing LINQ with XML and Databases
    - An Introduction to LINQ
    - Querying LINQ to SQL: Basics
    - Completing a Simple Storefront with LINQ
    - Knowing Your Environment: the System.Environ...
    - Creating the Home Page for a Simple Storefro...
    - LINQ Quickly with Language Integrated Queries





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT