Results 1 to 13 of 13

Thread: Aaro4130's Codes

Threaded View

  1. #1
    Junior Member
    Join Date
    Jul 10
    Posts
    22

    Arrow Aaro4130's Codes

    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:
    1. Public Function readINILine(ByVal file As String, ByVal section As String, ByVal key As String)
    2.         Dim sectionReached = False
    3.         For Each line In System.IO.File.ReadAllLines(file)
    4.             If sectionReached = True Then
    5.                 If line.StartsWith(key) Then
    6.                     Return line.Substring(line.IndexOf("=") + 1, line.Length - line.IndexOf("=") - 1)
    7.                 End If
    8.             End If
    9.             If line = "[" & section & "]" Then
    10.                 sectionReached = True
    11.             End If
    12.         Next
    13.     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:
    1. Public Function decodeRLE(ByVal input As String)
    2.         Dim decode = False
    3.         Dim curchar
    4.         Dim returnstr
    5.         For Each c As Char In input
    6.             If decode = True Then
    7.                 For i = 1 To Convert.ToDouble(c.ToString)
    8.                     returnstr &= curchar
    9.                 Next
    10.                 decode = False
    11.                 GoTo 1
    12.             End If
    13.             curchar = c
    14.             decode = True
    15. 1:
    16.         Next
    17.         Return returnstr

    Code 3 : RLE String Encoding
    Description : Encodes a string to RLE
    Usage Example : encodeRLE("Aaro4130")

    vbnet Code:
    1. Public Function encodeRLE(ByVal input As String)
    2.         Dim curchar = ""
    3.         Dim RL = 1
    4.         Dim output = ""
    5.         For Each c As Char In input
    6.             If c = curchar Then
    7.                 RL += 1
    8.             Else
    9.                 output &= curchar & RL
    10.                 RL = 1
    11.  
    12.             End If
    13.             curchar = c
    14.         Next
    15.         output &= curchar & RL
    16.         RL = 0
    17.         Return output.Substring(1, output.Length - 1)
    18.     End Function

    The codes provided here are free to use for anyone!
    Last edited by aaro4130; Apr 26th, 2013 at 06:30 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •