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 › Visual Basic Programming › [Tutorial]Convert Bits 2 Bytes

[Tutorial]Convert Bits 2 Bytes

Posts 1–8 of 8 · Page 1 of 1
NextGen1
NextGen1
[Tutorial]Convert Bits 2 Bytes
Convert Bits to Bytes and Bytes to Bits

In this tutorial we will learn how to make a Program to convert bytes to bits and Vice versa,

  • As always , create a new vb.net project
  • Name it ConvertBits (or whatever you like)
  • On your form you are going to add


  1. 2 Texboxes
  2. 2 Radio Controls
  3. 1 CheckBox
  4. 1 Label
  5. 2 Buttons


  • Arrange them however you like (you can use the below image for guidance)



[IMG]http://i111.photobucke*****m/albums/n121/golmor/controls.png[/IMG]

  • Set the Text for the following controls to


  1. Radio Control 1 - To Bits
  2. Radio Control 2 - To Bytes
  3. CheckBox - Abbreviated
  4. Button 1 - Convert
  5. Button 2 - Exit


  • Change the name of your label to lblbit


It should look something like this

[IMG]http://i111.photobucke*****m/albums/n121/golmor/byts1.png[/IMG]

As always here is the code, I have noted everything you will need to know in order to learn from this example

Code:
Option Strict On
Imports System.Convert

Public Class Form1
    'True = Bytes to bits
    'False = bits to Bytes

    Dim objBitByte As New Converter()

    Private Sub ButtonX1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX1.Click
        If CheckBox1.Checked = False Then
            'Unabbreviated output
            TextBox2.Text = objBitByte.Convert(CLng(TextBox1.Text), RadioButton1.Checked)
        Else
            'Abbreviated output
            TextBox2.Text = objBitByte.Format(CLng(objBitByte.Convert(CLng(TextBox1.Text), RadioButton1.Checked)), RadioButton1.Checked)
        End If
    End Sub

    Private Sub ButtonX2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX2.Click
        Me.Close()

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged
        'Change lblBit to display "Bytes" when converting to bits
        If RadioButton1.Checked = True Then
            lblbit.Text = "Bytes"
        End If
    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged
        'Change lblBit to display "bits" when converting to Bytes
        If RadioButton2.Checked = True Then
            lblbit.Text = "bits"
        End If
    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
        If Not IsNumeric(TextBox1.Text) Then
            TextBox1.Clear()
        End If
    End Sub
End Class
Public Class Converter

#Region "Methods"

      Function Convert(ByVal intBitByte As Int64, ByVal blnType As Boolean) As String
        If blnType = True Then
            'Convert from bits to Bytes 
            Try
                Return CStr(intBitByte * 8)
            Catch err As ApplicationException
                MessageBox.Show(err.Message)
            End Try
        Else
            'Convert from Bytes to bits 
            Try
                Return CStr(intBitByte \ 8)
            Catch err As ApplicationException
                MessageBox.Show(err.Message)
            End Try
        End If
    End Function

    Function Format(ByVal intData As Int64, ByVal blnType As Boolean) As String
        Dim strData As String
        If intData < 1024 Then
            If blnType = False Then
                'B
                strData = CStr((intData) & " B")
                Return strData
            Else
                ' b
                strData = CStr((intData) & " b")
                Return strData
            End If
        ElseIf intData >= 1024 And intData < 1048576 Then
            If blnType = False Then
                ' KB
                strData = CStr((intData * 10 ^ -3) & " KB")
                Return strData
            Else
                'Kb
                strData = CStr((intData * 10 ^ -3) & " Kb")
                Return strData
            End If
        ElseIf intData >= 1048576 And intData < 1073741824 Then
            If blnType = False Then
                ' MB
                strData = CStr((intData * 10 ^ -6) & " MB")
                Return strData
            Else
                ' Mb
                strData = CStr((intData * 10 ^ -6) & " Mb")
                Return strData
            End If
        ElseIf intData >= 1073741824 And intData < 1099511627776 Then
            If blnType = False Then
                'GB
                strData = CStr((intData * 10 ^ -9) & " GB")
                Return strData
            Else
                'o Gb
                strData = CStr((intData * 10 ^ -9) & " Gb")
                Return strData
            End If
        ElseIf intData >= 1099511627776 And intData < 1125899906842624 Then
            If blnType = False Then
                'TB
                strData = CStr((intData * 10 ^ -12) & " TB")
                Return strData
            Else
                ' Tb
                strData = CStr((intData * 10 ^ -12) & " Tb")
                Return strData
            End If
        Else
            MessageBox.Show("ERROR: overflow", "Program does not support EB/Eb or higher!", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
        End If
    End Function

#End Region
    Public Class Form1
        'True = Bytes to bits
        'False = bits to Bytes

        Dim objBitByte As New Converter

    End Class
End Class
End Function in Region may give errors, pay no mind to it.

[IMG]http://i111.photobucke*****m/albums/n121/golmor/bits2.png[/IMG]

Hope This helps Someone

' As always you may have to change the control names to make this work for your program
' Didn't include the source for this one yet, I will sometime soon
' Just in a rush this morning
#1 · edited 16y ago · 16y ago
kaaskiller
kaaskiller
Is there any difference between a radiobutton and a checkbox? just wondering
#2 · 16y ago
NextGen1
NextGen1
In a sense, though the outcome can be achieved using either or.

*radiobuttons only allow one decision
checkboxs allow the selction of mulitiple options.

Example:

RadioButton
-----------
Gender = o Male o Female
Animal = o Cat o Dog

CheckBox
--------
Favorite programming languages
o Visual Basic o C++ o Assembly

here you can select all 3
#3 · edited 16y ago · 16y ago
Lolland
Lolland
Helpful tutorial, GJ nextgen.
#4 · 16y ago
NextGen1
NextGen1
Quote Originally Posted by lolland View Post
Helpful tutorial, GJ nextgen.
Thanks , Hope this helps here
#5 · 16y ago
XG
XGelite
nice tutorial!
#6 · 16y ago
guza44_44
guza44_44
nice tutorial and btw do u use VB 10 cus ur buttons look different O.o
#7 · 16y ago
NextGen1
NextGen1
I use VB 10 (on occasions)but not in this case, the buttons are ButtonXControls.
The downloads for all of the UI Components are found in my

How To:UI Tutorial
and
Download:UI Components

Hope this helps
#8 · edited 16y ago · 16y ago
Posts 1–8 of 8 · Page 1 of 1

Post a Reply

Similar Threads

  • [Tutorials]Array of BytesBy Str8Soulja00 in Visual Basic Programming
    3Last post 18y ago
  • Ace of Spades 0.61 some bits & bytesBy learn_more in Other First Person Shooter Hacks
    15Last post 14y ago
  • Assembly basic's #1 - Bits Bytes and other Shyte :)By GG2GG in Assembly
    4Last post 17y ago
  • Convert Byte to MbBy Zoom in Visual Basic Programming
    5Last post 16y ago
  • Converting Assembly Into BytesBy radnomguywfq3 in Visual Basic Programming
    0Last post 19y ago

Tags for this Thread

None