The Snowman Super Whackaweed Vampire
Joined: 05 Nov 2007 Posts: 295
HP: 95 MP: 10 Lives: 0
|
Posted: Thu Apr 03, 2008 4:33 am
|
|
|
Welcome, Digibutter! This is a tutorial for Visual Basic 6!
MODS: Feel free to edit or reformat!
Different parts of this tutorial were wrote at different times All of this was written out of my head with a few tested codes.
Here it is..
Summary
In this tutorial I will teach you the standards or basics of Microsoft Visual Basic 6.0. This tutorial will have three sections. First it will have a section on all the controls that Visual Basic 6.0 offers, then it will explain different statements such as
if statements, and statements, or statements, and a few other functions. Then I will show you a few calculations you can use to make your application do a lot more. Let’s get started…..
Toolbar
First I will teach you about the different controls in the toolbar on the left.
Run VB6 (That is what Visual Basic 6.0 will be called in this tutorial.) Then a window will pop-up after a few seconds. Choose Standard.exe which is a regular application.
Now on the left side of the screen, you will see a toolbar that has some pictures of the controls. You can put your mouse over these to read the name of them
The controls are Pointer, Picture box, Label, Text box, Frame, Command Button, Check Box, Option Box, Combo Box, List Box, H Scroll Bar, V Scroll Bar, Timer, Drive List Box, Directory List Box, File List Box, Shape, Line, Image, Data, OLE.
Not all of the properties will be explained because some are used very rarely.
Controls
The Pointer is what you will use the whole time unless you’re in the process of adding a control.
A Picture Box is basically what its name says. It’s a little different then an image because this is enclosed in a box. All you do is click this control then click and drag on the form or window you see in the middle of the screen that looks like your
app. As your dragging the picture box will become bigger and smaller. Once you have added it to your application, you can click on it and on the right hand side you will see a properties box. This will let you choose many different options for the
Picture Box. When you scroll through the properties you will see one called picture. To select a picture you want in the Picture Box click the little button on the left side of the column for the Picture property. You can experiment with all the other
properties to see what they do. Now that you know how to get the properties window of an object I will just refer to that as properties and not explain the “Drag, make bigger or smaller, and click to get the properties window process.”
A label works the same way. Just click, drag, and make it the size you want. Then in the properties window you will see a few things. It first has a Back Color property. Click that, click the down arrow, and select palette. Then select a color and you
will see that it is the background color for the label. The next important property is Caption. Click this then type in the space. As you see whatever you type in the caption box is what the label will say. The third most important property is Fore
Color. That is what the font color of the label will be. Do it the same way as you did for the Back Color and select a different color.
A Text Box is a box that contains text that you want. In this it will allow users to read, copy, paste, cut, and use the regular options you can on text. Add this to your form by clicking the control and dragging it to make it the appropriate size for
what you are writing. It has the Back Color and Fore Color which do the same things as they do on the label. If you scroll down you will see a property called Multi Line. This will let you select if you want it to continue going in one continues line or
if you want it to have a multiple number of lines. Then instead of having a caption property, it is called Text. When you type it will appear in the box as you type it. If you have Multi Line set to true, it won’t appear until you click out of the
properties window so don’t get frustrated when it doesn’t show up immediately. Once again, you can scroll through the properties to see what they do.
The next option is a Frame. This will let you place controls in it so when you move the frame it will move with them. The only way to get a control in a frame is to put it on your form in the frame. If you make the control outside the frame it will no
longer be able to go in it. The frames are used mainly for option buttons so that if you select an option in one frame, It will not unselect an option in another frame. The frame has the caption, Fore Color, and Back Color, properties which work the
same as they do with other controls. You add all the controls to the form the same way.
The next control is what most people would refer to as the most important. It is a command button. This is just a button. It is used to activate anything. Using a button is a standard in almost every VB6 made application. A button has a few tricks in
its properties. It has the Back Color option so you can change that. When you change it, you will see it doesn’t change colors. That it because you have to scroll down through the properties of it and select the Style property. As you will see, it is set
to Standard. Change it from Standard to Graphical. After you do this you will see that the color changes immediately. The command button does not have a Fore Color option. Some downloadable buttons called Chameleon Buttons will have this option
but not the standard Command Button made by Microsoft. Then it has the Caption option which will also be what the Command Button says. Like I said, these controls have A LOT more properties but I only talk about the important ones.
Check Boxes and Option Boxes are the same. The only difference is a Check Box is a check, and an Option Box is a circle. These are used as an on and off button in one. They use a code which will later be explained. I will do a brief code.
Code: |
If option1 (or check1) .value = 1 thenDo whateverElseDo something elseEnd if
|
They also have the standard properties.
Combo Boxes and List Boxes are also a lot alike. The only difference is that the List Box is spread out visible and a Combo Box is in a drop down menu. To add an option to the combo box you just do this code in the Sub Form Load code which you
get by double clicking on your form.
Code: |
Combo1 (or List1) .additem “Name Here” Then to make it do something you use this codeCode: If Combo1 = "Name1" ThenMsgBox "You Selected Name1"ElseMsgBox "You Selected Something Other Than Name1"End if
|
Then a Combo Box and List Box also have most of the standard properties.
H Scroll Bars and V Scroll Bars aren’t used a lot so I will not discuss these. If you would like these to be added to the tutorial, post about it.
A timer is the next control. These are used a lot to. The interval in the properties window is the number of milliseconds it will do something. If you set the interval to 1, it will do what you want it to do every millisecond. Many things can be done in
this. Timers are used for hotkeys most of the time. You can also have cheats in them like Self Med, Bookmarker, Telespeed, Telefly, and many more.
The only other control I am going to talk about is an Image. It is exactly the same as a Picture Box, only it is flat. All the controls are the same so there is nothing else to talk about.
Now I am going to talk about the Forms properties. You can change the size of the form by just clicking it, then moving the sides like you would resize any program. The form has the Caption, Back Color, and Fore Color properties. It also has a few
other properties. Min Button and Max Button just tell you if the top of the window has a Minimize Button and Maximize Button. Then you can set the border style. 0 is borderless, 1 is normal, 2 is non resizable without a minimize or maximize
button. A tool window just makes it smaller. You can look at all of the other properties because a lot of them are needed and will come in handy most of the time when you are making a VB6 application.
Application
Now let’s start making our first application.
Add a module by doing the following.
In the top right corner you see a box that says all the forms, modules, and projects you have. Right click in a blank spot on that and hit Add Module. Now a window will pop up. Double click the module option. In the white box that pops up add this code
Code: |
Public Declare Function Hotkey Lib "user32" Alias "GetAsyncKeyState" (ByVal Key As Long) As Integer
|
This makes it so that to use a hotkey, you use this code
Different Statements
Code: |
If Hotkey (vbKeyU) thenDo somethingEnd if
|
If Statements
If statements do exactly as they say. It just says that If you do whatever, then something happens. You can use an Else to makes it so if something happens it does this, and anything else, It does this.
That goes in a code like this.
Code: |
If Hotkey (vbKeyU) thenDo somethingElseDo something elseEnd if
|
You can also use elseif statements. Instead of making it is if does something else in general, an elseif statements makes it so that if you do something, a function will happen, if you do something else that you have told it to do, then it will do another
specific thing.
That goes in a code like this.
Code: |
If Hotkey (vbKeyU) thenDo somethingElseif Hotkey (vbKeyH) thenDo something elseEnd if
|
And Statements
Now we will talk about and statements.
An and statement basically just allows you to do two things, or requires 2 things. And statements will ask for 2 things
That goes in a code like this
Code: |
If Hotkey (vbKeyU) and Hotkey (vbKeyH) thenDo whateverEnd if
|
That is basically all and statements do.
Or Statements
The next function we will talk about is an or statement.
An or statement gives to user two options. For example, you make two buttons the hotkey for exiting out of your program.
That goes in a code like this.
Code: |
If hotkey (vbKeyU) or Hotkey (vbKeyH) thenUnload me ‘You can also use Unload Form1 or whatever your form name isEnd if
|
That is all there is to know about or statements
Let’s go over a little review of what we just learned.
We learned that and if statement just tells something to happen only IF whatever you want is done.
An and statement tells something to work only if two things are done at once.
Or statements give the user multiple options to do one thing and it gives the program a choice of what it does.
Else statements make it so if ANYTHING ELSE happens then do this.
Elseif statements make it so if SOMETHING SPECIFIC happens then do this.
New Summary
Here is the more advanced tutorial.
In this tutorial I will teach you about variables and integers. I will get started on strings but I will not go into them too much. I will just teach you how to read different parts of a phrase depending on how many letters to the left or right they are.
Also it will read both left and right to pinpoint a section in the middle of the text.
Let’s get started…
Variables
Variables are actually pretty simple. Anyone who made it to the 5th grade should know what they are. All they are is something that stands for something else. Here’s a simple math problem:
In that problem the letter x is the variable. The x stands for the number 145 because 145 + 353 = 498.
That’s how a variable works.
To put that in a code you do it like this.
Code: |
dim myvariable as variableMyvariable = text1If myvariable = “Hello” thenUnload meEnd if
|
That just makes it so you can type the variable instead of text1
It would be a lot easier to do it this way:
Code: | dim myvariable as variablet1 = text1If t1 = “Hello” thenUnload meEnd if
|
The usual point of variables is to make it so the creator of the application doesn’t have to type out a long name every time he wants to have the control included in a function.
That is all there really is to know about variables.
Integers
The next function is integers
Integers are used a lot in calculators.
This is a mistake a lot of people who try creating a calculator make.
This is there code
Code: | If txtmathsign.text = “+” thentxtanswer.text = txtnum1 + txtnum2Elseif txtmathsign.text = “-“ thentxtanswer.text = txtnum1 – txtnum2End if
|
You can try that code if you want to see if I’m telling the truth. For the adding, if the first number is 5 and the second number is 6, it won’t make the answer 11. It will make the answer 56. It will do this because it does not know that those textboxes
contain integers.
This would be the correct code:
Code: | Dim txtnum1 as integerDim txtnum2 as integerDim txtanswer as integerIf txtmathsign.text = “+” thentxtanswer.text = txtnum1 + txtnum2Elseif txtmathsign.text = “-“ thentxtanswer.text = txtnum1 – txtnum2End if
|
Now you can test this It will make it so txtanswer is txtnum1 + txtnum2 because it now knows that those are both integers.
That is really all there is to know about integers.
Strings (A Little Knowledge)
Strings allow you to read only certain parts of a phrase or sentence that is written allowing you to pinpoint in exact spots.
The Left Function
The Left function allows you to read so many letters or characters from the left of the beginning.
This is how it works.
Code: | Dim Left5 as StringDim LeftText as StringLeftText = text1.textLeft5 = Left$(LeftText, 5)
|
All this does is set text1 so its called LeftText and Let use know that Left5 is 5 to the left of LeftText. In the ()’s the 5 means how many letters that we should go to the left of whatever was declared before the, which is LeftText
That is the Basics of The Left Function…
The Right Function
The right function is the same as the left function only it goes from the right.
This is how it works.
Code: | Dim Right5 as StringDim RightText as StringRightText = text1.textRight5 = Left$(RightText, 5)
|
All this does is set text1 so its called RightText and Let use know that Right5 is 5 to the right of RightText. In the ()’s the 5 means how many letters that we should go to the right of whatever was declared before the, which is RightText
The Middle Function
The middle function reads text from so much to the left, then so much to the right.
Here’s how it works.
Code: | Dim MiddleText as StringDim TheMiddle as StringMiddleText = text1.text TheMiddle = mid$(MiddleText, 3,
|
That just says it will read the text from the 3rd letter of what’s in text1 to the 8th letter of what’s in text1.
Start of the newer tutorial (Advanced)
In this tutorial we will talk more about strings, (The Len Function and The InStr Function). It will also go over a few of the symbols in VB6 and how you can use them. Then I will teach you how to start making your own code. That is basically what we will be doing but I will teach a little more as see stuff on the web to talk about. Just sit
back and read this. Then read again and insert the codes that time. Enjoy…
Let’s get started…
First we are going to talk about the different signs
Operator Meaning = Equal to > More than < Less Than >= More than or equal <= Less than or equal <> Not Equal to
These are used in a lot of different programs. I’ll give you an example of a full programs code. This program is used to tell what the age section of the person is just by the age they enter.
Follow this tutorial.
Make a command button and a textbox. Set the caption of the command button to “Calculate My Age” Without the quotations. Set the text for the text box to “” (Nothing).
Now double click the command button and enter this code, it will all be commented.
Code: | Private Sub Command1_Click ()If text1.text >= “1” and <= “5” thenMsgBox “You Are” + text1.text + “So you are a toddler”Elseif text1.text >= “6” and <= “12” thenMsgBox “You Are” + text1.text + “So you are a preteen”Elseif text1.text >= “13” and <= “19
” thenMsgBox “You Are” + text1.text + “So you are a teenager”Elseif text1.text >= “20” and <= “35” thenMsgBox “You Are” + text1.text + “So you are a young adult”Elseif text1.text >= “36” and <= “54” thenMsgBox “You Are” + text1.text + “So you are
middle aged”Elseif text1.text >= “55” and <= “69” thenMsgBox “You Are” + text1.text + “So you are an Elder”Elseif text1.text >= “70” and <= “132” thenMsgBox “You Are” + text1.text + “So you are ANCIENT”End IfEnd Sub
|
That will just tell the user what age group they are in if they enter their age. It is one of the simplest codes next to a calculator.
I gave away most of the calculator code earlier but it was not the whole calculator.
+ Means add - Means subtract * Means Multiply / Means Divide
Those are all used in a calculator.
Remember, in a calculator, you have to dim the textboxes that have the numbers in them as integers or else some of the functions will not work. Another statement I forgot about was the Xor statement. It just means that one side or other must be true but not both. It’s basically like an or statement but not exactly. That concludes the signs part of this tutorial.
Now let’s talk about more string functions. First the Len Function
The Len Function just tells you how many characters are in a text box or phrase.
This is how you use it in a code.
Code: | Dim LenText as StringDim TextLength as LongLenText = text1.textTextLength = Len (LenText)
|
See how simple it is. All that does is tell you how many characters there are in whatever you put in the ()’s.
Now let’s take about another function
The InStr Function
The InStr function will tell you if a string is within a string and where it starts.
Here’s how the code can be used…
Code: | Dim InStrText as StringDim TheString as LongInStrText = “Lmao OMG”TheString = InStr (InStrText, “OMG”)
|
I don’t know too much about this so I can’t explain anymore. I hope that helped enough though.
That is it for the string section of this tutorial
Now I am going to teach you the final part of this tutorial.
Making your own code…
To do this you have to understand what you are doing and also understand a little more about Visual Basics 6.0 then what my tutorials have taught you. Making your own code isn’t the easiest thing and I still struggle to make my own code in many
different things.
For a lot of things to make your own code you use components. To open the components window, open visual basic, select standard.exe, and then press Ctrl+T.
I will only teach you how to make a simple add-on program to the standard Windows Media Player. All I am going to do is tell you the standard functions and how to find them. All you do is find a component that is related to something. Then in a
code type the controls name after you’ve added it and then put a . After it and you will see all the options it allows you to use. For Windows Media Player there will be Play, Pause, Stop, Rewind, Fast Forward, and stuff like that. I will explain how to
make a full working code to get a play list to show up and stuff like that but I want to save that so I have something long to write about on my fourth tutorial. I hope this tutorial has helped you and recommend it to all of your friends. Remember…
This newer tutorial will just go over a few different things that have been posted and gone over but I will explain them a little more so the beginners learn something instead of just copying and pasting. These will include options such as allowing
users to get their own hotkeys, and making custom menu’s. Also as I have said recently, it will also go over a few different things that I can exactly think of at the moment.
Here is the new tutorial.
Custom Hotkeys
Let’s start off with custom hotkeys.
For now on, add this module into every project you make in this tutorial. http://www.cheatzcity.com/Trainer%5FModule%5Fv6.bas
Theses are actually pretty simple, they just involve using the keypress event in a textbox and read the KeyAscii of the key pressed, and then add the KeyAscii into the textbox that you had typed into.
Let’s start out with the code:
Code: | Private Sub Text1_KeyPress (KeyAscii as Integer)Text1.Text = KeyAsciiEnd Sub
|
That means that when you press a key in the textbox, it shows up as the KeyAscii. Set text1’s MaxLengh to 2 That is in the properties window of text1.
Now in a timer with the interval set to 1 and enabled to false, add this code
Code: | Private Sub Timer1_Timer ()If GetKeyPress(Text1) Then‘Do whatever you want text1's hotkey to doEnd If End Sub
|
Now add a command button Add this code.
Code: | Private Sub Command1_Click ()Timer1.enabled = trueEnd Sub
|
That makes it so the hotkeys are enabled
Now add another command button and add this code
Code: | Private Sub Command2_Click ()Timer1.enabled = falseEnd Sub
|
That makes it so the hotkeys are editable at that time until u press Command1 again.
That’s all I have to say about custom hotkeys. There is a lot you can add on but that is all that is necessary.
Now on to the next thing...
Game Trainer
This part will teach you how to make a cheat or trainer for a game of your choice.
First of all, if you don’t know how to find the addresses for trainers, learn that first
You need this program to find them though
http://www.cheatzcity.com/TSearch.zip
Don’t use the TMK to VB converter. It will not work for the new trainer module. The trainer module is linked in this tutorial earlier. But let’s get back to the tutorial.
After you find the addresses, open vb and add the module. Now add 2 command buttons.
In the Sub Form_Load () add this code
Code: | Private Sub Form_Load ()CurrentProcess = "Window Name Here"End Sub
|
There are multiple ways of finding the window name, Google it.
In the “Cheat ON” command buttons code, add this.
Code: | Private Sub Command1_Click ()Call WriteByteString (&HCheatAddressHere, “ValuesWithoutSpaces”)End Sub
|
In the “Cheat Off” command buttons code, add this.
Code: | Private Sub Command1_Click ()Call WriteByteString (&HCheatAddressHere, “ValuesWithoutSpaces”)End Sub
|
That time do the code for the off button.
That’s basically how you make a simple game trainer using the trainer module “Made by Whackaweed"
Hope you learned something! That was a long time...
EDIT: There may be some errors on the code spacing, so put in some spaces! |
|