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] Tokenizer - VB 2010

Smile[Tutorial] Tokenizer - VB 2010

Posts 1–11 of 11 · Page 1 of 1
MJLover
MJLover
[Tutorial] Tokenizer - VB 2010
[Tutorial]Simple Tokenizer that can be used in parsers.

Here we go:

First, create a module and create a public function named "TokenizeLine":

Code:
Public Function TokenizeLine(ByVal line As String)

End Function
Inside this function add the following lines of code:

Code:
Dim BCO As Integer = 0
Dim bcc As Integer = 0

	Dim g As String = ""
        Dim q As Boolean = False
        Dim bracket As Boolean = False


        For i As Integer = 1 To line.Length
            Dim c As String = Mid(line, i, 1)

            If c = """" Then
                If q Then
                    q = False
                Else
                    q = True

                End If
            End If
            If q Then
                g += c
                Continue For
            End If

            If Not q Then
                If c = "(" Then

                    BCO += 1
                    bracket = True

                    If BCO > 1 Then
                        If BCO = bcc Then
                            g += vbCrLf

                        End If
                    Else
                        g += vbCrLf

                    End If


                End If

                If c = ")" Then
                    bcc += 1
                    If BCO = bcc Then
                        g += c
                        bracket = False
                        BCO = 0
                        bcc = 0

                    End If


                End If

                If bracket Then
                    g += c
                    Continue For
                End If
            End If

            If Char.IsLetter(c) Then
                g += c
            ElseIf Char.IsDigit(c) Then
                g += c

            ElseIf Char.IsWhiteSpace(c) Then
                g += vbCrLf
            ElseIf c = "+" Or c = "-" Or c = "/" Or c = "*" Or c = "=" Or c = "." Or c = "<" Or c = ">" Or c = "_" Then
                g += vbCrLf & c & vbCrLf
            ElseIf c = """" Then
                If Not q Then
                    g += """"
                End If
            End If

            
        Next
        Dim f() As String = g.Split(ChrW(10))
        Dim ic As String = ""
        For Each j As String In f
            If Char.IsWhiteSpace(j) Then
                j = j.Replace(j, "")

            End If
            ic += j

        Next
        ic = ic.Trim
        Return ic
Explaination:
'These two integers will keep record of opened and closed brackets.
Dim BCO As Integer = 0
Dim bcc As Integer = 0

'Will keep the final value.
Dim g As String = ""
'Checks whether a double quote is opened or not.
Dim q As Boolean = False
'Checks if a bracket is opened or not.
Dim bracket As Boolean = False

'Loop through every character of the line.
For i As Integer = 1 To line.Length

'Stores a single character.
Dim c As String = Mid(line, i, 1)

'If current character is a double quote;
If c = """" Then
'Check the value of variable q and invert the value;
If q Then
q = False
Else
q = True
End If
End If

'If double quote is found then, append the character and continue Loop;
If q Then
g += c
Continue For
End If

'If current character not a double quote;
If Not q Then
'If current character is an opened bracket
If c = "(" Then
'Increment the variable BCO
BCO += 1
'Put the 'bracket' to true;
bracket = True

'If count of opened brackets is greater than 1
If BCO > 1 Then

'If count of opened brackets = count of closed brackets
If BCO = bcc Then
'Append a newline;
g += vbCrLf
End If
Else
g += vbCrLf
End If
End If


'If current character is a closed bracket
If c = ")" Then
'Increment closed bracket's counter
bcc += 1
'If count of opened brackets = count of closed brackets
If BCO = bcc Then
'Increment the character ")" to the string
g += c
'Put 'bracket' to False
bracket = False
Put the two variables (That keep the record of brackets) to '0'
BCO = 0
bcc = 0
End If
End If


'We want to keep everything in line when a bracket is opened
If bracket Then
'So, append the string with the current character unless the bracket is closed.
g += c
'Continue the loop (Without executing rest of the lines)
Continue For
End If


'Check if the current character is a letter (alphabet)
If Char.IsLetter(c) Then
'If so, append it
g += c
'Check if the current character is a digit
ElseIf Char.IsDigit(c) Then
'If so, append it
g += c
'If a whitespace is found
ElseIf Char.IsWhiteSpace(c) Then
'Just insert a newline
g += vbCrLf
'If one of the following character's is found, seperate each of them by inserting a newline
ElseIf c = "+" Or c = "-" Or c = "/" Or c = "*" Or c = "=" Or c = "." Or c = "<" Or c = ">" Or c = "_" Then
g += vbCrLf & c & vbCrLf

'If a double quote is found.
ElseIf c = """" Then
'And if double quote is already opened.
If Not q Then
'Just put a double quote to close it.
g += """"
End If
End If

'Loop
Next

'Create a string to split the contents of the variable 'g'. Split them by newline.
Dim f() As String = g.Split(ChrW(10))
'Create an empty string to store the value
Dim ic As String = ""

'Loop through the splitted string
For Each j As String In f
'If a whitespace is found, just replace it by an empty string value
If Char.IsWhiteSpace(j) Then
j = j.Replace(j, "")
End If
'Increment the value of 'j' into 'ic'
ic += j
'Loop
Next
'Trim the value of 'ic'
ic = ic.Trim
'Return the final value
Return ic


Example:
Create a form. Add a richtextbox, a button and a treeview. Arrange them.
Rename the richtextbox to 'rtb' and rename the treeview to 'tv'

Now double click the button and add the following code in it:
Code:
'Clear the Treeview
tv.Nodes.Clear()
'Set the line number to 1
Dim ln = 1
'Loop through the lines of richtextbox
For Each x As String In rtb.Lines
'If current line is not an empty line
If Not x = vbNullString Then
'Add the current line number to treeview 'tv'
tv.Nodes.Add("Line No: " & ln)
'Create a string that will keep the splitted line (current line)
Dim tokens As String() = TokenizeLine(x).ToString.Split(vbCrLf)
'Loop through every token created after splitting
For Each n As String In tokens
'Add the token to its respective line number
tv.Nodes(tv.Nodes.Count - 1).Nodes.Add(n)
'Loop
Next
End If
'Increment the line number
ln += 1
Next
First it is created in Visual Basic 2010 Beta 2, so many might be unable to open it !!

Required Virus Scans

Here's the screenshot:

Attachment scans:
Virus Total... Symantec BS as always, rest is clear

Virus Scan.org Tokenizer_********* MD5: cbf96b6ecdf781a0f914e1702d5b90a6 didnot find malware.
#1 · edited 16y ago · 16y ago
NextGen(1)
NextGen(1)
A tokenizer is something that reads input and returns a token if a match was found. If no match is found, it returns Nothing.

is this Vb.net? Or Vb6.......

And, Screenshot, Virus Scan, And then you can Re-Upload, I removed it until then

I know you are new, But please goto the rules section and read it.

Thanks

I merged Your postss and deleted your other posts, Use the edit key, no need to double post or to create a new post when the initial is under 24 hours.

oh and /Approved
#2 · edited 16y ago · 16y ago
mnpeepno2
mnpeepno2
This looks cool, but i knew it.
#3 · 16y ago
NextGen(1)
NextGen(1)
Quote Originally Posted by mnpeepno2 View Post
This looks cool, but i knew it.
You seem to know everything....
#4 · 16y ago
mnpeepno2
mnpeepno2
I got the book you told me to get!!!!

The Programmer's Cookbook


/Offtopic
You are unbanned...
#5 · 16y ago
NextGen(1)
NextGen(1)
Wait, when did I get banned?... And it's a good read
#6 · 16y ago
neofar
neofar
copied/pasted
#7 · 16y ago
MJLover
MJLover
LOL, we must make something special that mnpeep don't know !!
#8 · 16y ago
NextGen1
NextGen1
Posts delete, stay on topic, no flaming, no spam, I will delete posts that are, and I will suggest a ban if it happens again

Do this section a favor, read the extensive rules, and follow them

Thanks

#9 · 16y ago
MJLover
MJLover
Quote Originally Posted by NextGen1 View Post
Posts delete, stay on topic, no flaming, no spam, I will delete posts that are, and I will suggest a ban if it happens again

Do this section a favor, read the extensive rules, and follow them

Thanks

OK, I am sorry, but you see I didn't started !!
#10 · 16y ago
NextGen1
NextGen1
Quote Originally Posted by MJLover View Post
OK, I am sorry, but you see I didn't started !!
Meh, I am not a mean person, But Just don't "take the bait"

Anything Personal Or Private (for the most part) can be handled via Private Message


#11 · edited 16y ago · 16y ago
Posts 1–11 of 11 · Page 1 of 1

Post a Reply

Similar Threads

  • Injecting, texture modding and model changing! 27/4/2010By Jarppi in Combat Arms Mod Tutorials
    294Last post 11y ago
  • PlayerStats Editor 1.0.184 (UPDATED VERSION 2-19-2010) and EAM + Tutorial for Both!!By Koen in Call of Duty 6 - Modern Warfare 2 (MW2) Hacks
    180Last post 16y ago
  • [Tutorial]Injecting, texture modding and model changing! 27/4/2010By Jarppi in Combat Arms Mods & Rez Modding
    3Last post 16y ago
  • MPGH Public Hack 06-26-2010 TutorialBy TigerTJE in CrossFire Tutorials
    55Last post 16y ago

Tags for this Thread

#vb.net string tokenizer