First of all, don't copy this.
Features of this tutorial are
- Creating check boxes that work.

- Reading/writing a float value. ( Superjump )
- Understanding pointers.
- Creating a password for a trainer.
Source code found below for each of these programs
Superjump
This is assuming that you have the module released by TheRedEye. There is an addition to the module in this tutorial. Be sure to add it as it is important.
First off, open the past module. If you don't have the module, then add the whole thing. If you have the module already, then add just the blue part.
Code:
Public Const PROCESS_ALL_ACCESS = &H1F0FFF
Dim f1holder As Integer
Dim timer_pos As Long
'API Declaration
Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal Classname As String, ByVal WindowName As String) As Long
Public Declare Function GetKeyPress Lib "user32" Alias "GetAsyncKeyState" (ByVal key As Long) As Integer
Public Declare Function ReadProcessMem Lib "kernel32" Alias "ReadProcessMemory" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByRef lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Public Function WriteAByte(gamewindowtext As String, address As Long, value As Byte)
Dim hWnd As Long
Dim pid As Long
Dim phandle As Long
hWnd = FindWindow(vbNullString, gamewindowtext)
If (hWnd = 0) Then
MsgBox "The Game Is Not Working", vbCritical, "Error"
End
Exit Function
End If
GetWindowThreadProcessId hWnd, pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If (phandle = 0) Then
MsgBox "Can't get ProcessId", vbCritical, "Error"
Exit Function
End If
WriteProcessMemory phandle, address, value, 1, 0&
CloseHandle hProcess
End Function
Public Function WriteAnInt(gamewindowtext As String, address As Long, value As Integer)
Dim hWnd As Long
Dim pid As Long
Dim phandle As Long
hWnd = FindWindow(vbNullString, gamewindowtext)
If (hWnd = 0) Then
MsgBox "The Game Is Not Working", vbCritical, "Error"
End
End If
GetWindowThreadProcessId hWnd, pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If (phandle = 0) Then
MsgBox "Can't get ProcessId", vbCritical, "Error"
Exit Function
End If
WriteProcessMemory phandle, address, value, 2, 0&
CloseHandle hProcess
End Function
Public Function WriteALong(gamewindowtext As String, address As Long, value As Long)
Dim hWnd As Long
Dim pid As Long
Dim phandle As Long
hWnd = FindWindow(vbNullString, gamewindowtext)
If (hWnd = 0) Then
MsgBox "The Game Is Not Working", vbCritical, "Error"
End
Exit Function
End If
GetWindowThreadProcessId hWnd, pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If (phandle = 0) Then
MsgBox "Can't get ProcessId", vbCritical, "Error"
Exit Function
End If
WriteProcessMemory phandle, address, value, 4, 0&
CloseHandle hProcess
End Function
Public Function ReadAByte(gamewindowtext As String, address As Long, valbuffer As Byte)
Dim hWnd As Long
Dim pid As Long
Dim phandle As Long
hWnd = FindWindow(vbNullString, gamewindowtext)
If (hWnd = 0) Then
MsgBox "The Game Is Not Working", vbCritical, "Error"
End
Exit Function
End If
GetWindowThreadProcessId hWnd, pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If (phandle = 0) Then
MsgBox "Can't get ProcessId", vbCritical, "Error"
Exit Function
End If
ReadProcessMem phandle, address, valbuffer, 1, 0&
CloseHandle hProcess
End Function
Public Function ReadAnInt(gamewindowtext As String, address As Long, valbuffer As Integer)
Dim hWnd As Long
Dim pid As Long
Dim phandle As Long
hWnd = FindWindow(vbNullString, gamewindowtext)
If (hWnd = 0) Then
MsgBox "The Game Is Not Working", vbCritical, "Error"
End
Exit Function
End If
GetWindowThreadProcessId hWnd, pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If (phandle = 0) Then
MsgBox "Can't get ProcessId", vbCritical, "Error"
Exit Function
End If
ReadProcessMem phandle, address, valbuffer, 2, 0&
CloseHandle hProcess
End Function
Public Function ReadALong(gamewindowtext As String, address As Long, valbuffer As Long)
Dim hWnd As Long
Dim pid As Long
Dim phandle As Long
hWnd = FindWindow(vbNullString, gamewindowtext)
If (hWnd = 0) Then
MsgBox "The Game Is Not Working", vbCritical, "Error"
End
Exit Function
End If
GetWindowThreadProcessId hWnd, pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If (phandle = 0) Then
MsgBox "Can't get ProcessId", vbCritical, "Error"
Exit Function
End If
ReadProcessMem phandle, address, valbuffer, 4, 0&
CloseHandle hProcess
End Function
Public Function ReadAFloat(gamewindowtext As String, address As Long, valbuffer As Single)
Dim hWnd As Long
Dim pid As Long
Dim phandle As Long
hWnd = FindWindow(vbNullString, gamewindowtext)
If (hWnd = 0) Then
MsgBox "The Game Is Not Working", vbCritical, "Error"
End
Exit Function
End If
GetWindowThreadProcessId hWnd, pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If (phandle = 0) Then
MsgBox "Can't get ProcessId", vbCritical, "Error"
Exit Function
End If
ReadProcessMem phandle, address, valbuffer, 4, 0&
CloseHandle hProcess
End Function
Public Function WriteAFloat(gamewindowtext As String, address As Long, value As Single)
Dim hWnd As Long
Dim pid As Long
Dim phandle As Long
hWnd = FindWindow(vbNullString, gamewindowtext)
If (hWnd = 0) Then
MsgBox "The Game Is Not Working", vbCritical, "Error"
End
Exit Function
End If
GetWindowThreadProcessId hWnd, pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If (phandle = 0) Then
MsgBox "Can't get ProcessId", vbCritical, "Error"
Exit Function
End If
WriteProcessMemory phandle, address, value, 4, 0&
CloseHandle hProcess
End Function
Once added, the function ReadAFloat and WriteAFloat are now available. Sweet. Now on to writing superjump into your program. This is also an alright example of pointers.
I'm going to throw the code out there. The explanation
Code:
If GetKeyPress(vbKeyControl) And GetKeyPress(vbKeySpace) Then
'Defines the keys to activate the change under this If statement.
Dim SJ As Long
Dim SJ1 As Long
Dim SJ2 As Single
'Defines the variables to be set and what type of value type they are.
'Make sure the last variable is set to a single.
Call ReadALong("WarRock", &H896E28, SJ)
'Reads a long value type from the address 00896E28 and sets the outcome
'of that to the variable SJ
SJ1 = SJ + &H180
'Sets SJ1 to the variable set earlier (SJ) + the pointer 180.
SJ2 = Text1.Text
'SJ2 is set to what number is in the text box.
Call WriteAFloat("WarRock", SJ1, SJ2)
'Writes a FLOAT at the point SJ1 (address + pointer) and sets it to
'what is in the text box.
End If
'Ends the If statement for the hotkeys.
The green is obviously not code in the above code, so don't try and edit it like a few people have and told me. "I put this in 'I want stamina to freeze. Freeze it'" and then expect VB to be able to read plain english. That's really hilarious but don't do it.
And there! By adding that, you have just created superjump in a Visual Basic program. If you want to know more about superjump or if your code doesn't seem to be working correctly for what ever reason, there is a source code below for an actual superjump program.
If you want to create a check box for superjump as well then look at the source code for a superjump program below.
Password Protection
This code allows a separate form for a password entry onto another form. Of course the code can be edited slightly if you wish to do so.
Add the following code to a timer in your first form. The explination is in the code itself.
Code:
If GetKeyPress(vbKeyReturn) Then
'Return/Enter is set to start the code below. A button can also
'be used if you wish to do so.
If Text1.Text = "passwordhere" Then
'If the text box text has the password in it then it will execute
'the code under the If.
Form2.Show
Form1.Hide
Form1.Enabled = False
Form2.Enabled = True
Else: MsgBox "Incorrect Password"
'If the password is not correct, it will display the message box
'with Incorrect Password in it.
Text1.Text = ""
'Resets the text box to make it blank again.
End If
'Ends the If Text1.Text statement.
End If
'Ends the Hotkey Return/Enter to activate the password attempt.
Of course if you'd like to make a button for this instead of a hotkey, you can create the button and add the code inside the button ( minus the hotkey line of course ).
The next code in your form you are going to open when the password is correct is
important. Without this code, the program will not close correctly. Explained more in the code itself below.
Code:
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
Dim Object As Object
Dim Form As Form
For Each Form In Forms
For Each Object In Form
Set Object = Nothing
Unload Object
Next
Set Form = Nothing
Unload Form
Next
Unload Me
End
End Sub
'The Code above is used for the closing of the application.
'If this code wasn't added, the program will still be in the
'process list when you attempted to close it, and you
'will then get runtime errors when attempting to run it
'again. Add this to the form you'd like to make the whole
'program close once the form itself has been closed.
'If you'd like you can try it without this code, but you
'will then see yourself running into problems with more than
'one form and closing the entire application.
Add what you'd like to the form of course. Notice that when you close the program it actually ends the process. Nice.
That's the end of this tutorial/examples. If you have problems, download the source codes below. Don't redistribute them as your own please. I'd appreciate it. +Rep me if I helped at all. Respond to this post if it helped you out to let people know it's working or with questions.