Aaro4130's Codes
About me!
Hey! I'm Aaron, a 16 year old programmer from Toronto, ON, I started into programming when I was only 8 years old! I started into Visual Basic from MS Word, and then got it at home and it took off, I am now fluent in VB.NET and I know some C# as well as Java!
Codes in this thread :
- INI File Reading (Function)
- RLE String Decoding (Function)
- RLE String Encoding (Function)
- Fading form (Tutorial)
- Windows 7 Snap Emulation (Source For Predefined Sub)
- Titlebar blocker
---------------------
Code 1 : INI File read
Description : Will read a value from an INI File
Usage Example : Textbox1.text = readINILine("C:\ini.ini","TestSection","TestKey)
vbnet Code:
Public Function readINILine
(ByVal file As String,
ByVal section
As String,
ByVal key
As String) Dim sectionReached = False
For Each line In System.
IO.
File.
ReadAllLines(file) If sectionReached = True Then
If line.StartsWith(key) Then
Return line.Substring(line.IndexOf("=") + 1, line.Length - line.IndexOf("=") - 1)
End If
End If
If line = "[" & section & "]" Then
sectionReached = True
End If
Next
End Function
Code 2 : RLE Decoding (1 digit Runlengths)
Description : Will decode and return a run length string (such as A3A3R3O3431303)
Usage example : MsgBox(decodeRLE("A3A3R3O3431303")) or Textbox1.Text = decodeRLE("A3A3R3O3431303")
VB.NET Code:
vbnet Code:
Public Function decodeRLE(ByVal input As String)
Dim decode = False
Dim curchar
Dim returnstr
For Each c As Char In input
If decode = True Then
For i = 1 To Convert.ToDouble(c.ToString)
returnstr &= curchar
Next
decode = False
GoTo 1
End If
curchar = c
decode = True
1:
Next
Return returnstr
Code 3 : RLE String Encoding
Description : Encodes a string to RLE
Usage Example : encodeRLE("Aaro4130")
vbnet Code:
Public Function encodeRLE(ByVal input As String)
Dim curchar = ""
Dim RL = 1
Dim output = ""
For Each c As Char In input
If c = curchar Then
RL += 1
Else
output &= curchar & RL
RL = 1
End If
curchar = c
Next
output &= curchar & RL
RL = 0
Return output.Substring(1, output.Length - 1)
End Function
The codes provided here are free to use for anyone!