Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

VB for Beginners - Part 1 - Introduction

for beginner

  • Please log in to reply
20 replies to this topic

#1 Vswe

Vswe

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1989 posts
  • Programming Language:Java, C#, PHP, Python, JavaScript, PL/SQL, Visual Basic .NET, Lua, ActionScript

Posted 09 May 2009 - 03:27 AM

Hello everyone. These tutorials is made for someone who want to start learn programming or just have started with VB.Net since that is what I'm going to teach you. You don't need any experience at all.





Well, let's get started. VB.Net is a very good language for a beginner, it looks like English and is easy to use.

First you're going to need Visual Basic. It's where you'll write your programs, you can find a link Under Downloads/Comunity/MS Downloads in the top menu of this forum.



After you have installed Visual Basic and then started it, you will come to the Start Page. Click File in the menu and select New Project... or you can simply just press Ctrl+N on your keyboard. Now you will see a new window asking you what template you want to use for your program.
We're going to use "Windows Forms Application", make sure it's selected. Then we're going to select a name for our project.
Note: This is not the name of the program, just the project name.
I name mine "TestApplication". Then Prees OK.


Now we'll come to the design view of our project. As default you have the layout of the program in the middle. This is how the program looks like. In the design view it's drag-and-drop editing. You just move things with the mouse and resize them and so on.




But before we continue we'll need to rename our form. It's good to learn this right from the beginning: "The name of an object should tell what it is and what it is for."
So we want to rename Form1 (this is the form you can see in the middle, a program can be made of more then on form) to MainForm. This is so you (by only seeing the name) know it's a form and that it's our main one.

You maybe thinks it isn't so important to have good name, why can't I just have Form1,Form2 and Form3? Well, in programs with a few items you can't remember what everything does, and it's best to learn it the right way from the beginning.

To change the name of our form click on Form1.vb in the menu in the upper-right corner. In this menu you can see everything in your project (and even the whole solution, but you don't need to think about that).
Then go to the menu below the other menu ans change File Name from "Form1.vb" to "MainForm.vb". In this other menu you can change the properties of the selected object.





You maybe have noticed that it still stands Form1 on the form in the middle. Thats because the text of the form is still "Form1". Click on the form in the middle.
Now you will see a long list in the properties menu. Now we're going to change some values here. Change Text to "My First Program".




If you want to see your program you can press F5. It's not so much to see though since it's just an empty form.
Save you project by clicking save all under file in the top menu. The first time you'll need to select the name, it's just to press ok since we already have chosen the name.



In the next Part we'll work with items and some simple code.
Take care. :D
  • 1

#2 Guest_Jordan_*

Guest_Jordan_*
  • Guest

Posted 11 May 2009 - 06:40 AM

Not bad. How about some screenshots? :)
+rep
  • 0

#3 Vswe

Vswe

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1989 posts
  • Programming Language:Java, C#, PHP, Python, JavaScript, PL/SQL, Visual Basic .NET, Lua, ActionScript

Posted 11 May 2009 - 06:47 AM

Thanks... Maybe I should add some picture. I planned to upload part 2(I have currently made to part 4) when this was confirmed but now I have it on wrong computer.
  • 0

#4 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 11 May 2009 - 08:49 AM

So we want to rename Form1 (this is the form you can see in the middle, a program can be made of more then on form) to MainForm. This is so you (by only seeing the name) know it's a form and that it's our main one.


I disagree with this. What about standard naming conventions? Any professional will recommend naming your main form frmMain, in the same way a text box containing your postcode should be txtPostcode.
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#5 Vswe

Vswe

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1989 posts
  • Programming Language:Java, C#, PHP, Python, JavaScript, PL/SQL, Visual Basic .NET, Lua, ActionScript

Posted 11 May 2009 - 09:31 AM

I disagree with this. What about standard naming conventions? Any professional will recommend naming your main form frmMain, in the same way a text box containing your postcode should be txtPostcode.


How can you disagree with a argument which is agreeing with what I said? The frm shows it's a form and the txt show that it's a textbox.
  • 0

#6 Guest_Jordan_*

Guest_Jordan_*
  • Guest

Posted 11 May 2009 - 10:47 AM

He is stating the frm instead of Form. Many .NET books and teachers preach this standard but there is no right or wrong when it comes to naming conventions.

Posted via CodeCall Mobile
  • 0

#7 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 11 May 2009 - 11:10 AM

Indeed there is not, but from personal experience I have learnt that:

1) Using the same "frm" extension for forms makes things a huge amount easier to manage in code.
2) Putting the type of control at the start of the name instead of at the end is far preferable for coding, especially in projects (like this one) that use Microsoft's Visual Studio Express IDE. The reason for this is IntelliSense - when typing a reference to a form object, you need only type "frm" and the entire name of the form comes into view. The other way round, you would need to memorise the name of each form that you have in your project in order to call it up for manipulation.
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#8 Vswe

Vswe

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1989 posts
  • Programming Language:Java, C#, PHP, Python, JavaScript, PL/SQL, Visual Basic .NET, Lua, ActionScript

Posted 11 May 2009 - 11:22 AM

Xav, you must have understood what I wrote wrong, I wrote:

"The name of an object should tell what it is and what it is for."


This part doesn't say you should name it Form, just that you should name it something so you know it's a form.
  • 0

#9 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 11 May 2009 - 11:23 AM

Yes, this part certainly doesn't say you should name it Form.

But if you read the next sentence you wrote, it says that "we want to rename Form1 (this is the form you can see in the middle, a program can be made of more then on form) to MainForm". :)
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#10 Vswe

Vswe

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1989 posts
  • Programming Language:Java, C#, PHP, Python, JavaScript, PL/SQL, Visual Basic .NET, Lua, ActionScript

Posted 11 May 2009 - 11:32 AM

Yes, that's true. So you mean that you always should name your application for TestApplication?
  • 0

#11 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 11 May 2009 - 11:40 AM

I'm not talking about naming applications. You should name the application based on its purpose.

With controls, however, it makes a lot of sense to follow the naming conventions.
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#12 Vswe

Vswe

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1989 posts
  • Programming Language:Java, C#, PHP, Python, JavaScript, PL/SQL, Visual Basic .NET, Lua, ActionScript

Posted 11 May 2009 - 11:57 AM

I named my application TestApplication and my Form for MainForm, I didn't say you SHOULD do it, just that you should name it so you can now its type and its purpose.
  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download