Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › Programming Tutorials › Improve your Coding

Improve your Coding

Posts 1–15 of 60 · Page 1 of 4
Blubb1337
Blubb1337
Improve your Coding
Improve your coding

This is a small 'guide' on how to improve your coding and make it more clear. You can keep the overview, following these tips.

If I forgot anything, please remind me /Sticky plox.

Rename your controls

This is important to actually keep your code clean.

Do not keep the default control names like Button1/Textbox1.

Rename them.

Textbox1 = txtResult
Button1 = cmdCalculate

You can now easily recognize your events in your code, instead of having to search them.

Comment your code

This is obvious. You may forget stuff later on, therefore you can just add comments into your code.

[php]'comment[/php]

Use your datatypes correctly

Code:
Dim int as integer = "5"
Dim str as string = "Sample Text" 

txtResult.text = int
Integer <> String. Therefore the correct way is:

[php]Dim int as integer = 5[/php]

Shorten your code

Instead of writing:

Code:
txtResult.text = txtResult.text + int
You better use:

[php]txtResult.text += int[/php]

Furthermore:

[php]= 'obvious
<> 'not the same, Noob <> Pro
i <=5 'i is smaller than 5 or 5
i >=5 'i is bigger than 5 or 5
i < 5 'i is smaller than 5
i > 5 'i is bigger than 5
+ 'add
- 'substract
* 'multiply
/ 'division
[/php]

Using

Code:
Dim str as IO.Streamreader = New Streamreader("C:\test.txt")

txtResult.text = str.readtoend

str.dispose
[php]Using str as new Io.Streamreader("C:\test.txt")

txtResult.text = str.readtoend

End Using[/php]

Case instead of If

Code:
If txtResult.text = "a" Then
Msgbox("Newb")
End if

If txtResult.Text = "b" Then
Msgbox("Newbie")
End if

If txtResult.text = "c" Then
Msgbox("Noob")
End if
[php]Select Case txtresult.Text

Case "a"
Msgbox("Newb")

Case "b"
Msgbox("Newbie")

Case "c"
Msgbox("Noob")

End Select[/php]

If-Structures

If condition Then
[statements]
ElseIf condition Then
[statements]
Else
[statements]
End If

[php]If textbox1.text = "meh"
'do something
elseif Textbox1.text = "duh"
'do something else
else 'if it's neither meh nor duh
'something
end if[/php]

Using Case...

[php]Select Case Textbox1.Text
Case "meh"
'do something
Case "Duh"
'do something else
Case Else
'something
end select[/php]

[php]If Textbox1.text <> "" then 'if it's not empty
end if[/php]

If not...

[php]If not textbox1.text = "" then
end if[/php]

Booleans

[php]Dim b as boolean 'by default the boolean is FALSE[/php]

Code:
If b = true then
'do something
end if

If b = false Then
'do something
end if
[php]if b then 'true
'do something
else 'false
'do something
end if[/php]

Try-Catch

To avoid your program from closing when an error appears, you can use Try-Catch Blocks.

[php]Try
Timer.Value = txtResult.Text 'user may enter a letter instead of a number
Catch ex as exception
Msgbox(ex.Tostring) 'optional
End try[/php]

However, do not use them if they are not necessary.

Code:
Try
Timer.Value = nudValue.Value 'NumericUpDown
Catch ex as exception
end try
Regions

You can use Regions to make your code more clear.

[php]#Region "Settings"

Private Sub spStartup_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles spStartup.CheckedChanged
if spstartup then
my.settings.spStartup = true 'run singleplayer on startup
my.settings.save
end if
End sub

Private Sub mpStartup_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mpStartup.CheckedChanged
if spstartup then
my.settings.mpStartup = true 'run multiplayer on startup
my.settings.save
end if
End sub

#End region[/php]

Declare your own Subs/Function

You may have a lot of repetitive code. Therefore, you can shorten your code a lot by building functions or subs.

Code:
  'grenades
        If My.Settings.nade = true Then

                string1 = readdll2("cshell.dll")
                string2 = "&H" + Hex(string1 + &H108DFC8)
                Call ITZAMOBSVG(string2, 1337, 4)
           
        End If

        'flashs
        If My.Settings.flash = true Then

                string1 = readdll2("cshell.dll")
                string2 = "&H" + Hex(string1 + &H108DFD4)
                Call ITZAMOBSVG(string2, 1337, 4)
          
        End If

        'grenade launcher
        If My.Settings.gl = true Then

                string1 = readdll2("cshell.dll")
                string2 = "&H" + Hex(string1 + &H108DF64)
                Call ITZAMOBSVG(string2, 1337, 4)
           
        End If
[php]Private sub h4x(ByVal address as string, byval value as long, byval bytes as integer)
string1 = readdll2("cshell.dll")
string2 = "&H" + Hex(string1 + address)
Call ITZAMOBSVG(string2, value, bytes)
End sub[/php]

[php]If My.Settings.nade Then
h4x(&H108DFC8, 1337, 4)
End If

'flashs
If My.Settings.flash Then
h4x(&H108DFD4, 1337, 4)
End If

'grenade launcher
If My.Settings.gl Then
h4x(&H108DF64, 1337, 4)
End If[/php]

What is the difference between a function and a sub?

A function always returns something.

[php]Private Sub calculate(byval number1 as integer, byval number2 as integer)
textbox1.text = number1 + number2
end sub[/php]

[php]calculate(5,3)[/php]

[php]private function calculate(byval number1 as integer, byval number2 as integer)
return number1 + number2
end function
[/php]

[php]textbox1.text = calculate(5,3)[/php]

With

Code:
lblStatus.text = "Something"
lblstatus.BackColor = Color.Yellow 
lblstatus.Location = New Point(50, 100)
lblstatus.visible = true
[php]With lblstatus
.text = "Something"
.backcolor = color.yellow
.location = new point(50, 100)
.visibile = true
end with[/php]


Structure

Code:
Dim firstPos as point
Dim firstDir as string 
Dim firstFrame as integer

Dim secondPos as point 
Dim secondDir as string 
Dim secondFrame as integer

Dim thirdPos as point
Dim thirdDir as string
Dim thirdFrame as integer
[php]Structure meh
Dim Pos As Point
Dim Dir As String
Dim Frame As Integer
end structure

dim first as meh
dim second as meh
dim third as meh[/php]

[php]first.dir = "up"[/php]


I will try to update this topic with more improvements.

I do hope you will now code "cleaner". This will improve your coding. [/QUOTE]
#1 · edited 16y ago · 16y ago
Hassan
Hassan
Wow...nice tutorial boy. Love it. Thanks for sharing
#2 · 16y ago
Jason
Jason
Thanks Kevin, nice and informative guide you got there! I'm glad that it turns out that I do most of these already.

Really need to work on renaming controls -.- I can never be fucked but getting into long projects it's confusing as shit! (What does button32_click do again...?)

And commenting, I NEED DAT!
#3 · 16y ago
Blubb1337
Blubb1337
Quote Originally Posted by J-Deezy View Post
Thanks Kevin, nice and informative guide you got there! I'm glad that it turns out that I do most of these already.

Really need to work on renaming controls -.- I can never be fucked but getting into long projects it's confusing as shit! (What does button32_click do again...?)

And commenting, I NEED DAT!
Indeed, on my trainer I'm always like wut se fack what is this button again. So I click on form1...go on the specific tab click the button...owwww that one...

My File Sorter I did is very clean I guess =D
#4 · 16y ago
Sixx93
Sixx93
nice! good job dude
#5 · 16y ago
'Bruno
'Bruno
Leaving my controls as default name on my exams when i was studying last 3 years would be instant negative, and would need to repeat exam... actually most of what you typed there would make it negative. It was a must. And also commenting was really a must. (This in C# btw)

Plus i don't see much logic calling a button -> cmdSomething. Usually i call it btnSomething. It would also be confusing because of combo box's which i name them cmbSomething. (This in C# btw)

Anyway, its good.
#6 · edited 16y ago · 16y ago
Blubb1337
Blubb1337
Quote Originally Posted by Brinuz View Post
Leaving my controls as default name on my exams when i was studying last 3 years would be instant negative, and would need to repeat exam... actually most of what you typed there would make it negative. It was a must. And also commenting was really a must. (This in C# btw)

Plus i don't see much logic calling a button -> cmdSomething. Usually i call it btnSomething. It would also be confusing because of combo box's which i name them cmbSomething. (This in C# btw)

Anyway, its good.
Well I don't force you to use cmd, lol.

cbComboBox
cmdButton

This is the way I do it.

You can sure use

cmbComboBox
btnButton

It is your decision
#7 · 16y ago
Jason
Jason
Haha I still use cmd from the old VB6 days
#8 · 16y ago
'Bruno
'Bruno
Quote Originally Posted by Blubb1337 View Post
Well I don't force you to use cmd, lol.

cbComboBox
cmdButton

This is the way I do it.

You can sure use

cmbComboBox
btnButton

It is your decision
exactly. ^^ it was just an opinion ;o anyway could even call radiobuttons tits.. oO

btw you could add to that list about creating functions for some repetitive code. :\ thats one of the best ways to clean code.. and people usually don't care much about it... but in bigger projects.. its a pain..

it usually happens, eg: when accessing a database (people usually repeat the very same code a lot with it)
#9 · edited 16y ago · 16y ago
Abstract
Abstract
Good tutorial man
#10 · 16y ago
Jason
Jason
Quote Originally Posted by Brinuz View Post
exactly. ^^ it was just an opinion ;o anyway could even call radiobuttons tits.. oO

btw you could add to that list about creating functions for some repetitive code. :\ thats one of the best ways to clean code.. and people usually don't care much about it... but in bigger projects.. its a pain..

it usually happens, eg: when accessing a database (people usually repeat the very same code a lot with it)
Last topic of the thread is subs/functions? /
#11 · 16y ago
'Bruno
'Bruno
Quote Originally Posted by J-Deezy View Post


Last topic of the thread is subs/functions? /
nop not that.. it's about repetitive code... instead of always having for example the very same 5 lines of code or w/e to access a database on 20 different parts of them program, you could easily make a func.
Or for example instead of having the very same Cicle to take a values from a BD in 10 different parts of a program... make a func.

you see what i mean?

btw don't take me wrong, that tutorial it's really good and one of the most helpful tuts i have seen on mpgh.
#12 · 16y ago
Jason
Jason
Quote Originally Posted by Brinuz View Post
nop not that.. it's about repetitive code... instead of always having for example the very same 5 lines of code or w/e to access a database on 20 different parts of them program, you could easily make a func.
Or for example instead of having the very same Cicle to take a values from a BD in 10 different parts of a program... make a func.

you see what i mean?

btw don't take me wrong, that tutorial it's really good and one of the most helpful tuts i have seen on mpgh.
But that's exactly what the last part of the tut describes?
#13 · 16y ago
'Bruno
'Bruno
Quote Originally Posted by J-Deezy View Post


But that's exactly what the last part of the tut describes?
not quite the same imo... or maybe im expressing myself wrong? oO

edit: Actually i have looked to it now with more attention oO i though he was talking about something else and not about repetitive stuff. Anyway..
#14 · edited 16y ago · 16y ago
omanel
omanel
What's a boolean, what's it used to?
Yeah, I suck lol
#15 · 16y ago
Posts 1–15 of 60 · Page 1 of 4

Post a Reply

Similar Threads

  • Do you take drugs to improve your gameplay?By CAPTAIN OBVIOUS in General
    23Last post 18y ago
  • How Can I Improve This Code ?By kelechi96 in Combat Arms EU Hack Coding/Source Code
    8Last post 16y ago
  • [Request] Mechanical share your codeBy deadman027 in CrossFire PH Discussions
    13Last post 15y ago
  • HOW TO IMPROVE YOUR COMPUTERS FPS AND IN GENRAL!By Death217 in CrossFire Tutorials
    8Last post 15y ago
  • Improve your reactionBy Ferris Bueller in CrossFire Tutorials
    13Last post 15y ago

Tags for this Thread

None