You are viewing our Forum Archives. To view or take place in current topics click here.
VB TUT - Includes Leanring The Program And The Language
Posted:

VB TUT - Includes Leanring The Program And The LanguagePosted:

Undead-Tech-Modz
  • Challenger
Status: Offline
Joined: Feb 04, 201212Year Member
Posts: 113
Reputation Power: 4
Status: Offline
Joined: Feb 04, 201212Year Member
Posts: 113
Reputation Power: 4
Hello and welcome to my tut. This tut was made to only cover the basics. If this gets enough thanks and/or gets stickied, I will make this much more advanced. This tut took me hours to completely make and if my hard work gets the attention it deserves, I will also make another tut on another language. For now, this will do. If you would like to see something added or you think something should be added let me know:
Aim = Undead Tech
Pm me
Email = undead.tech @ ymail.com

First off, what is VB code language and what is it used in?
Its one of, if not is, the easiest and most basic form of coding. People use this coding in Microsoft's program, [ Register or Signin to view external links. ] . In this program you make other programs, basic programming.

[ Register or Signin to view external links. ]




What programs can you make in Visual Basic?
There are no limits to the number of different kinds of programs you can make! I've seen kinds of programs that include: educational programs (game teachers), business programs (inventory management system, financial management, payroll system, etc), gamers (modding programs), mp3/video players, pretty much anything!



Starting A Project
So first, I guess I should show you how to get started. Once you download it and get everything set-up, your going to want to run Visual Basic Express. That will bring you to the start page.

[ Register or Signin to view external links. ]

From there you'll need to click on "New Project". It will then bring you to a page like the one below...

[ Register or Signin to view external links. ]

From here you can make your programs.



So now you give it a try (Lesson1)
When you are on the "Create a new project" screen, choose "Windows Forms Application" because that is the most simple one and you are a beginner. At the bottom of the screen you will need to pick a name. Name it "Lessons" and then click OK. Add a textbox and a button from the "Toolbox". Your form should now look like this...

[ Register or Signin to view external links. ]

Now double-click on "Button1". It will take you to a code page. We're going to make it so when you click on the button, it will write "Hello" in the text box. When you're on the code page it should look like this...

[ Register or Signin to view external links. ]

The Public Class Form1 is stating that this is the code for Form1, which is the name of the window you're working on. The "Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click" is stating that your writing code for when you click on button1. The "End Sub" states the end of the coding for button1. Now for the coding... Im going to say the coding, then tell you what it means. Textbox1.Text = "Hello". Since this is in the button1.click part, it is saying that when you click on button1, insert text into the textbox saying Hello. What the coding should look like is below...

[ Register or Signin to view external links. ]

So now that we have the coding in, lets try out the program. Click on the green triangle in the toolbar at the top.

[ Register or Signin to view external links. ]

The form you just made should popup. Test to see that the coding is right by clicking on the button. If you typed everything correctly, it should say Hello in the textbox. If you didn't either nothing will show up or it will tell you there is an error. If everything ends up working corectly, then you have just passed Test1. When you are satisfied go to the next test"



Lesson2
Now lets learn strings. This part is pretty self explanatory. Delete the coding you just wrote. Before we add the string I'm going to explain a string to you. When you create a string you turn a whole line of coding into one word. For example if you write "Dim happy as string = "Hello, what up?" ", happy is the one word and "Hello, what up" is the whole line. So instead of having to write the whole line of coding, you can now just write happy. Now lets insert that into the project. You will want to write textbox1.text = happy. Your coding should look like mine...

[ Register or Signin to view external links. ]

Notice that I put the string above the private sub. Always put your strings here, it will just make things less complicated in the future. Debug (green arrow) your project and test if it works



Lesson3 - final test
Congrats on making it this far, this is the final test for now. we are going to make a questionare type thingy using a label, textbox, and a button and the code will use a If - End If feature. So like it says above add the needed features

[ Register or Signin to view external links. ]
(click on the object and change the "Text" in the properties window to match whats on the screen)

and delete all the code you just wrote. Now before we make any code, I'm going to tell you I use "Ifs" all the time and they're very important. Anyways so I'm 19, and so I'm going to make where if you type in that you're 18 or younger it says you're young, if you're 19 it will say you're neither young or old, and if you're 20 + i twill say your old. When you make it, you can set the ages up however you want. So first under the button code, we're going to type: if textbox1.text <=18 then textbox1.text = "Youre young". Like that. and if is always followed by a then. once you finish the code for the then, then you need and end if, which states that you're done writing the then code. If you want 2 ifs before the end if, then you will use else if. For example:

If textbox1.text <= 18 Then
Label1.Text = "You're Young"
ElseIf textbox1.text = 19 Then
Label1.Text = "You're Neither Young Or Old"

Then there would be an End If but there is one line of code missing. I want you to make this code. Use an ElseIf. You are going to want to write that everyone older than 19 is "Old", then insert the missing End If
#2. Posted:
Z61
  • V5 Launch
Status: Offline
Joined: Apr 16, 201014Year Member
Posts: 4,309
Reputation Power: 179
Status: Offline
Joined: Apr 16, 201014Year Member
Posts: 4,309
Reputation Power: 179
if its a test,why did you include the code?
#3. Posted:
Booker
  • New Member
Status: Offline
Joined: May 12, 201212Year Member
Posts: 13
Reputation Power: 0
Status: Offline
Joined: May 12, 201212Year Member
Posts: 13
Reputation Power: 0
damn this looks like a c+p to me i suggest you just go and hide in a cave
#4. Posted:
Undead-Tech-Modz
  • Challenger
Status: Offline
Joined: Feb 04, 201212Year Member
Posts: 113
Reputation Power: 4
Status: Offline
Joined: Feb 04, 201212Year Member
Posts: 113
Reputation Power: 4
Booker wrote damn this looks like a c+p to me i suggest you just go and hide in a cave


See if you can find anything like it on another website. I created everything here
[ Register or Signin to view external links. ]
#5. Posted:
AvP_Coding
  • Junior Member
Status: Offline
Joined: Jul 08, 201211Year Member
Posts: 68
Reputation Power: 2
Status: Offline
Joined: Jul 08, 201211Year Member
Posts: 68
Reputation Power: 2
Hate to gravedig an old topic but you're teaching people bad tricks. You should avoid using global variables...
A global variable can be get or set by any part of the program, and any rules regarding its use can be easily broken or forgotten. (In other words, get/set accessors are generally preferable over direct data access, and this is even more so for global data.) By extension, the lack of access control greatly hinders achieving security in situations where you may wish to run untrusted code (such as working with 3rd party plugins). I understand that this is just merely a 'Hello World' application, but in future you shouldn't use global variables as your first option.
#6. Posted:
Im_Blah
  • Challenger
Status: Offline
Joined: Jul 10, 201211Year Member
Posts: 134
Reputation Power: 5
Status: Offline
Joined: Jul 10, 201211Year Member
Posts: 134
Reputation Power: 5

You haven't really taught us anything about the GUI in VB?

You've taught us how to create the "Hello World" application, which can be found anywhere, mainly in Java.

I didn't learn anything from this.
#7. Posted:
GGR
  • TTG Senior
Status: Offline
Joined: Apr 25, 201113Year Member
Posts: 1,295
Reputation Power: 55
Status: Offline
Joined: Apr 25, 201113Year Member
Posts: 1,295
Reputation Power: 55
AvP_Coding wrote Hate to gravedig an old topic but you're teaching people bad tricks. You should avoid using global variables...
A global variable can be get or set by any part of the program, and any rules regarding its use can be easily broken or forgotten. (In other words, get/set accessors are generally preferable over direct data access, and this is even more so for global data.) By extension, the lack of access control greatly hinders achieving security in situations where you may wish to run untrusted code (such as working with 3rd party plugins). I understand that this is just merely a 'Hello World' application, but in future you shouldn't use global variables as your first option.


hes right, global variables should only be used as a last resort, it stops other codes working on the project coming up with the same variable names for example if programmer A uses the same variables as Programmer B then the project isnt going to work. its best to set local variables and pass them sub to sub. somthing like this:

Shared Sub Main()

Dim A As Integer
Dim B As Integer

Example(A,B)
WriteLine(A)
WriteLine(B)

End Sub

Shared Sub Example(C As Integer,D As Integer)
C = "Test1"
D = "Test2"

End SUB
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.