Visual Basic Tutorial 1 Of 20

  • Uploaded by: Bradley Fourie
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Visual Basic Tutorial 1 Of 20 as PDF for free.

More details

  • Words: 1,298
  • Pages: 12
Authors Notes: Before u start using visual studio 2008 you need to know a few fundamentals of its lay out, page this will get u familiar with what you will need to know at the beginning in order to do the tutorials, the tutorials will be in visual Studio 8 at first from here we will progress to c# and Asp.net one step at a time though. I want to make it clear I do not claim to be a pro programmer or anything like that I am self taught and the reason for these tutorials are because when I was first starting out I wished I had tutorials to follow to make the learning easier instead I discovered that people would rather boast of there knowledge rather than share it. So hopefully these help someone or you know of someone who wants to get into programming but doesn’t know where to start.

I Want to warn you if you are a complete beginning you going to struggle, just keep on reading try to understand and in the end you will Persevere; there will be more than one tutorial in this lesson because honestly not many People manage through the first tutorial of anything there first time so if you u get stuck Move on to the 2nd and 3rd get familiar with the interface and the rest will come to you Naturally, my girlfriend said something to me which makes so much sense but I never Realized it until she pointed it out she said programming is easier than language it’s self And she couldn’t be more right. Programming is basic and simple hopefully as time Passes u will realize this yourself.

Let’s get started! Application (Project) is made up of: •

Forms - Windows that you create for user interface



Controls - Graphical features drawn on forms to allow user interaction (Text boxes, labels, scroll bars, command buttons, etc.) (Forms and Controls are objects.)



Properties - Every characteristic of a form or control is specified by a Property. Example properties include names, captions, size, color, Position and contents. Visual Basic applies default properties. You Can change properties at design time or run time.



Methods - Built-in procedure that can be invoked to impart some action To a particular object.



Event Procedures - Code related to some object. This is the code that Is executed when a certain event occurs.



General Procedures – Code Not related to objects. This code must be Invoked by the application.



Modules - Collection of general procedures, variable declarations, and Constant definitions used by application.



Steps in Developing Application There are three primary steps involved in building a Visual Basic application: Draw the user interface Assign properties to controls Attach code to controls



Drawing the User Interface and Setting Properties Visual Basic operates in three modes. 1. Design mode - used to build application 2. Run mode - used to run the application 3. Break mode - application halted and debugger is available



We focus here on the design mode. Six windows appear when you start Visual Basic. The Main Window consists of the title bar, menu bar, and toolbar. The title bar indicates the project name, the current Visual Basic Operating mode, and the current form. The menu bar has dropdown Menus from which you control the operation of the Visual Basic environment. The toolbar has buttons that provide shortcuts To some of the menu options. The main window also shows the Location of the current form relative to the upper left corner of the Screen and the width and length of the current form.

The Layout (This is Important study it now!)

Part 1: Message Box Start visual basic 2008 and create a new project let’s call it “hello world”

Make sure the project type is Visual basic and you are using the windows form application template, and finally name the application “hello world” and click OK

Now navigate to you toolbox and on the common controls option in it, and look for the command button once located click on it and drag it across to your windows form.

You can also resize the form by left-clicking on any of the corners of the form holding it down and dragging it up and down, reposition the button and resize the form the way you want it to look.

Click on the Command button so it is selected then rename the text you see to click me you do so navigating to the properties box while the button is selected and by locating the Text field your are able to edit the displayed text. Your windows form should now look like this:

Double click on the click me button and another view shall be displayed this is the coding view this is where you will enter your code that will be executed on your applications click on event.

Between the Private Sub and End Sub type in the following code, msgbox “Hello world”

Now let’s test our application close the coding view and in the tool bar on top click the debug icon and this will run your application

This will temporarily build your application, click on the button and see what happens . . . a message box pops up saying hello world and that is how you create a message box please keep in mind you can change the text to whatever you want depending on your application.

Part 2: Menu Editor Now that you have built your application you need to make it truly yours and you can do this by adding a menu editor to your application you will be able to define what your product does and what version it is, you are also able to add your contact details in case anyone had any enquiries in the future. in the toolbox under menus and toolbars you will find the menu strip and same as how we dragged the button to the form we drag the menu strip to the top of the form.

If you were to click inside the menu strip notice how it expands:

Create the following menu headings,File,Donate,Contact,About your menu strip should look like this: Remember you can reposition and resize the form as you please

Double click on the word “Donate” in your menu strip and you will see the following, notice how you are now aloud to code behind the donate tab in the menu strip.

Add this message box code MsgBox("email:[email protected]")Do the same to the about and donate tabs you can add any message you want to appear il add the following About: MsgBox("verion 1.0") Donate: MsgBox("Contact me for more info")

These are your results when completed:

We are not done yet though, close your coding view and click on the file tab in your menu strip notice how a tab opens up below it:

Name that tab Quit and double click on it to enter the code view, between the Private Sub and End Sub type “End” like so:

And once again go to the tool bar above and debug your application, if you click on the tabs we created you will see your message boxes pop up and if you want to exit your application all you have to do is click Quit, Try it out now!

Part 3: Saving Projects Your application is almost complete go to file Save Form1.vb As..

Notice how the project saves to your my documents folder, Save it now

Now go to My Documents\Visual Studio 2008\Projects\hello world\WindowsApplication1: This is what you will See:

Open the bin folder then the debug folder:

When you run the WindowsApplication1.exe your program will start.

I hope this Tutorials help this is Vol1/20 Stay Tuned for more!

Related Documents


More Documents from ""