Visual Basic 2008 Personal Tips and Basic Codes
Read in thread or download as doc file: MEGAUPLOAD - The leading online storage and file delivery service (its looking really good thanks of Praesto)
Introducing
Visual Basic 2008 is a programming language created by Microsoft and is the easiest coding language i know to make your own windows applications. There are many things you can do with it like chat programs, databases and much much more. I wont go into any advanced things here but the basics can be used to many things.
Get Started
First of all you need to think of an app you want to do, then create the layout, place buttons, labels, trackbars,textboxes, more windows and other things you want.
It can be hard to know what everything is for but you will learn the more you work with it.
" I always finish all layout things before i start with the codes because if i place one thing and write the code for it before i place everything else i feel it's getting messy, i do change and add layout things later on so it looks better or get better functions and i do rename every button after i coded them to remember wich code that belongs to wich button."
Coding Basics
Here is the coding part and i first tell you that it's not easy if you are a beginner. To write a code just double click the button, textbar, picture or whatever you want to code. It will open another window where the codes shows. Visual Basic already gives you some start codes for the part you want to edit so you only need to write the code for what thething should do.
For example when you double click on an un-coded button it looks like
Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
End Sub should be in the end of every part you code, if not the code will try to work together with the next code that comes under it and that will cause problems when you try to build the app.
Same with Private Sub, it should always be in top of every code part.
In the beginning over all codes it should be Public Class Form1 and
End Class should be in the end under the rest of the codes.
If a code looks like
Code:
If TimeOfDay.Hour = (thehour) And TimeOfDay.Minute = (theminute) Then
Media.SystemSounds.Beep.Play()
End If
it must contains the End If at the end. I marked with blue the things you going to look at
"When i have many buttons i start to code button1 and keeps go in the number order. It's always easiest for me but some people probably go for the ones thats most important first."
Basic Codes and Explanation
Here i will set up a little list with codes to use and i will add a little explanation what it does for you.
Timer1.Start() starts Timer1. Timers can be used to create many different thing. I will take an example further down but no more.
Timer1.Stop() stops Timer1
Me.Close() Closes the form that the button is placed on.
Form1.Show() Opens Form1
Form1.Hide() Hides Form1
This is Basic Basic and doesnt have any big functions (except of form browsing)
Here comes some harder ones with more explanation
( I only use World of Warcraft as example )
Create an timer, doeble click and use this:
Code:
appactivate("World of Warcraft")
This one will activate the app so it "controls" you program a little bit (in this case World of Warcraft)
To get the timer "click" a button so your character walk a little bit every 5th second just click the timer and change the Interval to 5000 ( 5000 milliseconds = 5 seconds) now double click your timer and write:
This code will make the timer to click W button for you ever 5th second so it walks forward.
It's a little different with other buttons though.
Like Enter button looks like sendkeys.send: ("{ENTER}")
Tab : sendkeys.send("{TAB}")
and Space Bar : sendkeys.send("{SPACE}")
"I always think logical when i need a code. Look at the codes and you see that they are very logical. I always keep that in mind and it always helps me."
Application Building
Now when you think your done with you with you app you sure want it as a .exe file. But first you should test it and see if there is any errors, to do that press F5 Button and it will open a test of your app. Test it out and when you dont find any problems just close the app and go to the top and press Build then Build <YOUR APP NAME> and it normally appears in
Documents and Settings\Administrator\My documents\Visual Studio 2008\Projects\projectname\projectname\bin
Please dont flame because this is very basic.... i know its very very basic and its ment to be that. This is for users who want to start Visual Basic but dont know where to start. Sorry if i made some mistakes in grammar or spelling, english is my second language.
Whole this little Tut is made by me, though some of the codes comes from other guides on MMOwned.
Hope some of you like it though.