<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:dc="https://purl.org/dc/elements/1.1/">
	<channel>
		<title><![CDATA[BP Forums - Code Snippets]]></title>
		<link>https://bpforums.info/</link>
		<description><![CDATA[BP Forums - https://bpforums.info]]></description>
		<pubDate>Thu, 16 Apr 2026 18:23:37 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[Using the WebClient Class To Track Download Progress]]></title>
			<link>https://bpforums.info/showthread.php?tid=808</link>
			<pubDate>Fri, 23 Aug 2013 21:12:08 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://bpforums.info/member.php?action=profile&uid=1">brandonio21_phpbb3_import2</a>]]></dc:creator>
			<guid isPermaLink="false">https://bpforums.info/showthread.php?tid=808</guid>
			<description><![CDATA[Using this code snippet, you should be able to download any file to your computer and track it's progress using a progressbar or a label (Or any other control which you desire). Below is a sample snippet, so be sure to change variable names to match your project!<br />
<br />
[code2=vbnet]Imports System.Net<br />
Public Class Form1<br />
<br />
    Private Sub btn_downloadStart_Click(sender As System.Object, e As System.EventArgs) Handles btn_downloadStart.Click<br />
        Dim wc As New WebClient 'This allows us to actually download the files<br />
        AddHandler wc.DownloadProgressChanged, AddressOf DownloadProgressChanged 'Link the progresschanged event with our subroutine<br />
        AddHandler wc.DownloadFileCompleted, AddressOf DownloadFileCompleted 'Link the downloadfilecompleted event with our subrouting<br />
        wc.DownloadFileAsync(New System.Uri("File URL"), "Local Path") 'Actually download the file (on another thread), change File URL and Local Path to your information<br />
    End Sub<br />
<br />
    Public Sub DownloadProgressChanged(sender As Object, e As DownloadProgressChangedEventArgs)<br />
        progress_download.Value = e.ProgressPercentage 'Displays download progress on a progress bar<br />
        lbl_details.Text = e.BytesReceived &amp; "/" &amp; e.TotalBytesToReceive 'Displays download progress (as fraction) in a label<br />
    End Sub<br />
<br />
    Public Sub DownloadFileCompleted(sender As Object, e As EventArgs)<br />
        MsgBox("The file has completed downloading!") 'Tell the user the download is complete<br />
    End Sub<br />
End Class[/code2]<br />
<br />
A video tutorial for this code snippet should be coming soon!]]></description>
			<content:encoded><![CDATA[Using this code snippet, you should be able to download any file to your computer and track it's progress using a progressbar or a label (Or any other control which you desire). Below is a sample snippet, so be sure to change variable names to match your project!<br />
<br />
[code2=vbnet]Imports System.Net<br />
Public Class Form1<br />
<br />
    Private Sub btn_downloadStart_Click(sender As System.Object, e As System.EventArgs) Handles btn_downloadStart.Click<br />
        Dim wc As New WebClient 'This allows us to actually download the files<br />
        AddHandler wc.DownloadProgressChanged, AddressOf DownloadProgressChanged 'Link the progresschanged event with our subroutine<br />
        AddHandler wc.DownloadFileCompleted, AddressOf DownloadFileCompleted 'Link the downloadfilecompleted event with our subrouting<br />
        wc.DownloadFileAsync(New System.Uri("File URL"), "Local Path") 'Actually download the file (on another thread), change File URL and Local Path to your information<br />
    End Sub<br />
<br />
    Public Sub DownloadProgressChanged(sender As Object, e As DownloadProgressChangedEventArgs)<br />
        progress_download.Value = e.ProgressPercentage 'Displays download progress on a progress bar<br />
        lbl_details.Text = e.BytesReceived &amp; "/" &amp; e.TotalBytesToReceive 'Displays download progress (as fraction) in a label<br />
    End Sub<br />
<br />
    Public Sub DownloadFileCompleted(sender As Object, e As EventArgs)<br />
        MsgBox("The file has completed downloading!") 'Tell the user the download is complete<br />
    End Sub<br />
End Class[/code2]<br />
<br />
A video tutorial for this code snippet should be coming soon!]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Properties]]></title>
			<link>https://bpforums.info/showthread.php?tid=772</link>
			<pubDate>Fri, 12 Apr 2013 01:20:10 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://bpforums.info/member.php?action=profile&uid=1">brandonio21_phpbb3_import2</a>]]></dc:creator>
			<guid isPermaLink="false">https://bpforums.info/showthread.php?tid=772</guid>
			<description><![CDATA[Properties are essential if you are creating a custom object. Essentially, properties are the things that can be edited in the "visual designer" - all of the things that are accessible via the properties window in the lower right hand corner of Visual Studio.<br />
<br />
Adding basic properties to your form is easy. All you need is an instance variable and a property block. Then you're all set. For example, here is a sample property arrangemenet:<br />
[code2=vbnet]Private _messageString As String<br />
    Public Property MessageString As String<br />
        Get<br />
            Return _messageString<br />
        End Get<br />
        Set(value As String)<br />
            _messageString = value<br />
        End Set<br />
    End Property[/code2]<br />
<br />
Of course, in this example we use a <span style="font-style: italic;" class="mycode_i">String</span> object. In the real world, any object can be used. After this is added to your object, the user will be able to edit the properties via the properties Window and give this variable a specific value.<br />
<br />
What if you wanted to give the user a list of options to choose from, though? This can be doing by combining properties with enumerations. Thus:<br />
[code2=vbnet]Private _messageString As messageIdentifier<br />
    Public Property MessageString As messageIdentifier<br />
        Get<br />
            Return _messageString<br />
        End Get<br />
        Set(value As messageIdentifier)<br />
            _messageString = value<br />
        End Set<br />
    End Property<br />
<br />
    Enum messageIdentifier As Integer<br />
        Greetings = 1<br />
        Goodbyes = 2<br />
        Warning = 3<br />
        Declaration = 4<br />
    End Enum[/code2]<br />
<br />
Although the above code snippet may seem rather ridiculous since the Enumerations don't actually correspond to anything, this is a way of offering the user a list of options to choose from. In this case, the list will contain "Greetings", "Goodbyes", "Warning", and "Declaration". You can then work with this choice by processing the enumeration in some way, as such:<br />
[code2=vbnet]Private Function GetMessageString() As String<br />
        If (_messageString = messageIdentifier.Declaration) Then<br />
            Return "Of Independence"<br />
        ElseIf (_messageString = messageIdentifier.Goodbyes) Then<br />
            Return "It has been a fun time, but I must leave you."<br />
        ElseIf (_messageString = messageIdentifier.Greetings) Then<br />
            Return "Salutations, my good man/woman"<br />
        ElseIf (_messageString = messageIdentifier.Warning) Then<br />
            Return "Back off! You have no business in this area."<br />
        Else<br />
            Return ""<br />
        End If<br />
    End Function[/code2]<br />
<br />
<br />
Thus, it is really easy to give the user the ability to edit properties when they add your custom control to their form. The only downside occurs when you update a property to be a different object, but do not change the value of the property. Massive errors ensue.<br />
<br />
View the video here: &lt;!-- m --&gt;&lt;a class="postlink" href="http://www.youtube.com/watch?v=JAK6veamu8o&amp;feature=youtu.be"&gt;http://www.youtube.com/watch?v=JAK6veam ... e=youtu.be&lt;/a&gt;&lt;!-- m --&gt;<br />
<br />
Feel free to download a sample project:<br />
[attachment=0]&lt;!-- ia0 --&gt;PropertyTutorial.zip&lt;!-- ia0 --&gt;[/attachment]<br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://bpforums.info/images/attachtypes/zip.png" title="ZIP File" border="0" alt=".zip" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=117" target="_blank" title="">PropertyTutorial.zip</a> (Size: 74.13 KB / Downloads: 886)
<!-- end: postbit_attachments_attachment -->]]></description>
			<content:encoded><![CDATA[Properties are essential if you are creating a custom object. Essentially, properties are the things that can be edited in the "visual designer" - all of the things that are accessible via the properties window in the lower right hand corner of Visual Studio.<br />
<br />
Adding basic properties to your form is easy. All you need is an instance variable and a property block. Then you're all set. For example, here is a sample property arrangemenet:<br />
[code2=vbnet]Private _messageString As String<br />
    Public Property MessageString As String<br />
        Get<br />
            Return _messageString<br />
        End Get<br />
        Set(value As String)<br />
            _messageString = value<br />
        End Set<br />
    End Property[/code2]<br />
<br />
Of course, in this example we use a <span style="font-style: italic;" class="mycode_i">String</span> object. In the real world, any object can be used. After this is added to your object, the user will be able to edit the properties via the properties Window and give this variable a specific value.<br />
<br />
What if you wanted to give the user a list of options to choose from, though? This can be doing by combining properties with enumerations. Thus:<br />
[code2=vbnet]Private _messageString As messageIdentifier<br />
    Public Property MessageString As messageIdentifier<br />
        Get<br />
            Return _messageString<br />
        End Get<br />
        Set(value As messageIdentifier)<br />
            _messageString = value<br />
        End Set<br />
    End Property<br />
<br />
    Enum messageIdentifier As Integer<br />
        Greetings = 1<br />
        Goodbyes = 2<br />
        Warning = 3<br />
        Declaration = 4<br />
    End Enum[/code2]<br />
<br />
Although the above code snippet may seem rather ridiculous since the Enumerations don't actually correspond to anything, this is a way of offering the user a list of options to choose from. In this case, the list will contain "Greetings", "Goodbyes", "Warning", and "Declaration". You can then work with this choice by processing the enumeration in some way, as such:<br />
[code2=vbnet]Private Function GetMessageString() As String<br />
        If (_messageString = messageIdentifier.Declaration) Then<br />
            Return "Of Independence"<br />
        ElseIf (_messageString = messageIdentifier.Goodbyes) Then<br />
            Return "It has been a fun time, but I must leave you."<br />
        ElseIf (_messageString = messageIdentifier.Greetings) Then<br />
            Return "Salutations, my good man/woman"<br />
        ElseIf (_messageString = messageIdentifier.Warning) Then<br />
            Return "Back off! You have no business in this area."<br />
        Else<br />
            Return ""<br />
        End If<br />
    End Function[/code2]<br />
<br />
<br />
Thus, it is really easy to give the user the ability to edit properties when they add your custom control to their form. The only downside occurs when you update a property to be a different object, but do not change the value of the property. Massive errors ensue.<br />
<br />
View the video here: &lt;!-- m --&gt;&lt;a class="postlink" href="http://www.youtube.com/watch?v=JAK6veamu8o&amp;feature=youtu.be"&gt;http://www.youtube.com/watch?v=JAK6veam ... e=youtu.be&lt;/a&gt;&lt;!-- m --&gt;<br />
<br />
Feel free to download a sample project:<br />
[attachment=0]&lt;!-- ia0 --&gt;PropertyTutorial.zip&lt;!-- ia0 --&gt;[/attachment]<br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://bpforums.info/images/attachtypes/zip.png" title="ZIP File" border="0" alt=".zip" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=117" target="_blank" title="">PropertyTutorial.zip</a> (Size: 74.13 KB / Downloads: 886)
<!-- end: postbit_attachments_attachment -->]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Making Your Program Start with Windows]]></title>
			<link>https://bpforums.info/showthread.php?tid=771</link>
			<pubDate>Tue, 09 Apr 2013 23:10:35 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://bpforums.info/member.php?action=profile&uid=1">brandonio21_phpbb3_import2</a>]]></dc:creator>
			<guid isPermaLink="false">https://bpforums.info/showthread.php?tid=771</guid>
			<description><![CDATA[I know I have received several PMs and emails regarding making your VB.NET application start with Windows, and I finally got around to creating a nice code snippet.<br />
<br />
The first thing you need to do is as the "Windows Script Host Object Model" COM object as a reference to your project. This is very important.<br />
<br />
Next, you will want to import the reference:<br />
[code2=vbnet]Imports IWshRuntimeLibrary[/code2]<br />
<br />
Now you're good to go and you can start your application with Windows. Essentially, this code will create a shortcut in the users "Startup" folder, forcing Windows to start the application when the computer is turned on.<br />
<br />
This code will create the shortcut/start the program with Windows:<br />
[code2=vbnet]'create path variables<br />
        Dim startupPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Startup)<br />
        Dim executablePath As String = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName<br />
        Dim executableName As String = System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName<br />
        'create shortcut<br />
        Dim Shell As WshShell<br />
        Dim Link As WshShortcut<br />
        Try<br />
            Shell = New WshShell<br />
            Link = CType(Shell.CreateShortcut(startupPath &amp; "\" &amp; executableName &amp; ".lnk"), IWshShortcut)<br />
            Link.TargetPath = executablePath<br />
            Link.Save()<br />
        Catch ex As Exception<br />
            MsgBox(ex.Message)<br />
        End Try[/code2]<br />
<br />
This code will remove the shortcut/stop the program from starting with Windows:<br />
[code2=vbnet]Dim startupPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Startup)<br />
        Dim executableName As String = System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName<br />
<br />
        Dim directoryInfo As New System.IO.DirectoryInfo(startupPath)<br />
        Dim fileInfo() As System.IO.FileInfo<br />
        fileInfo = directoryInfo.GetFiles("*.lnk")<br />
        For Each file As System.IO.FileInfo In fileInfo<br />
            If (file.FullName.Contains(executableName)) Then<br />
                file.Delete()<br />
            End If<br />
        Next[/code2]<br />
<br />
<br />
Optionally, you can eliminate the deletion of files with similar names by changing <span style="font-style: italic;" class="mycode_i">file.FullName.Contains(executableName)</span> to <span style="font-style: italic;" class="mycode_i">file.FullName.Equals(executableName)</span><br />
<br />
<br />
Watch the video here: &lt;!-- m --&gt;&lt;a class="postlink" href="http://www.youtube.com/watch?v=VpPqPtTjMzQ&amp;feature=youtu.be"&gt;http://www.youtube.com/watch?v=VpPqPtTj ... e=youtu.be&lt;/a&gt;&lt;!-- m --&gt;<br />
<br />
<br />
[attachment=0]&lt;!-- ia0 --&gt;StartupTest.zip&lt;!-- ia0 --&gt;[/attachment]<br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://bpforums.info/images/attachtypes/zip.png" title="ZIP File" border="0" alt=".zip" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=115" target="_blank" title="">StartupTest.zip</a> (Size: 91.73 KB / Downloads: 967)
<!-- end: postbit_attachments_attachment -->]]></description>
			<content:encoded><![CDATA[I know I have received several PMs and emails regarding making your VB.NET application start with Windows, and I finally got around to creating a nice code snippet.<br />
<br />
The first thing you need to do is as the "Windows Script Host Object Model" COM object as a reference to your project. This is very important.<br />
<br />
Next, you will want to import the reference:<br />
[code2=vbnet]Imports IWshRuntimeLibrary[/code2]<br />
<br />
Now you're good to go and you can start your application with Windows. Essentially, this code will create a shortcut in the users "Startup" folder, forcing Windows to start the application when the computer is turned on.<br />
<br />
This code will create the shortcut/start the program with Windows:<br />
[code2=vbnet]'create path variables<br />
        Dim startupPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Startup)<br />
        Dim executablePath As String = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName<br />
        Dim executableName As String = System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName<br />
        'create shortcut<br />
        Dim Shell As WshShell<br />
        Dim Link As WshShortcut<br />
        Try<br />
            Shell = New WshShell<br />
            Link = CType(Shell.CreateShortcut(startupPath &amp; "\" &amp; executableName &amp; ".lnk"), IWshShortcut)<br />
            Link.TargetPath = executablePath<br />
            Link.Save()<br />
        Catch ex As Exception<br />
            MsgBox(ex.Message)<br />
        End Try[/code2]<br />
<br />
This code will remove the shortcut/stop the program from starting with Windows:<br />
[code2=vbnet]Dim startupPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Startup)<br />
        Dim executableName As String = System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName<br />
<br />
        Dim directoryInfo As New System.IO.DirectoryInfo(startupPath)<br />
        Dim fileInfo() As System.IO.FileInfo<br />
        fileInfo = directoryInfo.GetFiles("*.lnk")<br />
        For Each file As System.IO.FileInfo In fileInfo<br />
            If (file.FullName.Contains(executableName)) Then<br />
                file.Delete()<br />
            End If<br />
        Next[/code2]<br />
<br />
<br />
Optionally, you can eliminate the deletion of files with similar names by changing <span style="font-style: italic;" class="mycode_i">file.FullName.Contains(executableName)</span> to <span style="font-style: italic;" class="mycode_i">file.FullName.Equals(executableName)</span><br />
<br />
<br />
Watch the video here: &lt;!-- m --&gt;&lt;a class="postlink" href="http://www.youtube.com/watch?v=VpPqPtTjMzQ&amp;feature=youtu.be"&gt;http://www.youtube.com/watch?v=VpPqPtTj ... e=youtu.be&lt;/a&gt;&lt;!-- m --&gt;<br />
<br />
<br />
[attachment=0]&lt;!-- ia0 --&gt;StartupTest.zip&lt;!-- ia0 --&gt;[/attachment]<br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://bpforums.info/images/attachtypes/zip.png" title="ZIP File" border="0" alt=".zip" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=115" target="_blank" title="">StartupTest.zip</a> (Size: 91.73 KB / Downloads: 967)
<!-- end: postbit_attachments_attachment -->]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Editable Label]]></title>
			<link>https://bpforums.info/showthread.php?tid=722</link>
			<pubDate>Thu, 03 Jan 2013 19:28:46 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://bpforums.info/member.php?action=profile&uid=1">brandonio21_phpbb3_import2</a>]]></dc:creator>
			<guid isPermaLink="false">https://bpforums.info/showthread.php?tid=722</guid>
			<description><![CDATA[This is more of a control than a code snippet, but I wanted to share my "editable label" control anyway.<br />
<br />
The premise behind this control is the idea that users should be able to view and edit information; however, the ability to edit should remain non-intrusive. This is especially useful for people like on-phone tech-support who often need to view information but very rarely need to edit it. <br />
<br />
The control consists of the following items<br />
-A FlowLayoutPanel<br />
-Two Labels<br />
-A TextBox<br />
<br />
Here is the code behind the control:<br />
[code2=vbnet]Public Class ChangableLabel<br />
    '============================================================================<br />
    'ChangableLabel class created by Brandon Milton (brandonio21)<br />
    'This class was created specifically for a tutorial on the BrandonioProductions YouTube channel<br />
    '     You can find this channel at: &lt;!-- m --&gt;&lt;a class="postlink" href="http://youtube.com/BrandonioProductions"&gt;http://youtube.com/BrandonioProductions&lt;/a&gt;&lt;!-- m --&gt;<br />
    'Discussion of this class is held at BP Forums<br />
    '     A direct link to the thread: &lt;!-- l --&gt;&lt;a class="postlink-local" href="http://bpforums.info/viewtopic.php?f=22&amp;t=745"&gt;viewtopic.php?f=22&amp;t=745&lt;/a&gt;&lt;!-- l --&gt;<br />
    'Feel free to use this class in any way, but please remember to credit the author somewhere in the application<br />
    '=============================================================================<br />
<br />
    Public Property IdentifierText As String<br />
        'This property allows us to change the text of the first label when objectilized (sp?)<br />
        Get<br />
            Return lbl_identifier.Text<br />
        End Get<br />
        Set(value As String)<br />
            lbl_identifier.Text = value<br />
        End Set<br />
    End Property<br />
    Public Property InformationText As String<br />
        'This property allows us to change the text of the second label when objectilized (sp?)<br />
        Get<br />
            Return lbl_information.Text<br />
        End Get<br />
        Set(value As String)<br />
            lbl_information.Text = value<br />
        End Set<br />
    End Property<br />
<br />
    Private Sub lbl_information_MouseDoubleClick(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles lbl_information.MouseDoubleClick<br />
        'Here we want the textbox to appear<br />
        Dim oldLabel As Label = CType(flp_main.Controls.Item(1), Label) 'Save the label<br />
        flp_main.Controls.RemoveAt(1) 'Remove the label from the FlowLayoutPanel (so it can be replaced)<br />
<br />
        Dim txt_information As New TextBox 'Create textbox<br />
        Dim textboxSize As New Size(GetLabelWidth(oldLabel) + 25, txt_information.Size.Height) 'set size to ~ same size as label to avoid awkwardness<br />
        txt_information.Size = textboxSize 'set the size<br />
        txt_information.Text = oldLabel.Text 'set the text as old label text<br />
        AddHandler txt_information.KeyPress, AddressOf txt_information_keypress 'add handler to detect "enter" presses<br />
<br />
        flp_main.Controls.Add(txt_information) 'add the textbox to the FlowLayoutPanel<br />
    End Sub<br />
<br />
    Private Function GetLabelWidth(ByVal label As Label) As Integer<br />
        'This method gets the pixel width of labels<br />
        Dim g As Graphics = label.CreateGraphics() 'create graphix object for label to access info<br />
        Dim fontSize As SizeF 'var to save font sizes<br />
        fontSize = g.MeasureString(label.Text, label.Font) 'save the pixeled size of the label's text<br />
        Return fontSize.Width 'return the object (this is a function, afterall)<br />
    End Function<br />
    Private Sub txt_information_keypress(sender As Object, e As KeyPressEventArgs)<br />
        'this method is used to detect when the enter key is pressed on the textbox, return everything to normal state<br />
        If (e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Enter)) Then<br />
            Dim txt_information As TextBox = CType(sender, TextBox) 'save textbox var<br />
            Dim newLabel As New Label 'create new label<br />
            newLabel.AutoSize = True 'This gave lots of problems; allows for the control to resize with new label<br />
            newLabel.Text = txt_information.Text 'set the labels text to user input<br />
            AddHandler newLabel.MouseDoubleClick, AddressOf lbl_information_MouseDoubleClick<br />
            AddHandler newLabel.TextChanged, AddressOf ResizeControl<br />
            '^Adding handlers to resize the control and to detect double clicks, self-explanatory<br />
<br />
            'now we need to remove the textbox and add the label<br />
            flp_main.Controls.RemoveAt(1)<br />
            flp_main.Controls.Add(newLabel)<br />
<br />
<br />
            ResizeControl() 'resize the entire control to fit the new objects<br />
        End If<br />
    End Sub<br />
<br />
    Private Sub ResizeControl() Handles lbl_identifier.TextChanged, lbl_information.TextChanged<br />
        'this method resizes the control to fit the new objects and to make room for others around it<br />
<br />
        'create vars to hold size information<br />
        Dim identLabel As Label = CType(flp_main.Controls.Item(0), Label) 'save copy of first label<br />
        Dim infoLabel As Label = CType(flp_main.Controls.Item(1), Label) 'save copy of second label<br />
        Dim paddingSpace As Integer = 50<br />
<br />
        Dim width As Integer = GetLabelWidth(identLabel) + GetLabelWidth(infoLabel) + paddingSpace 'add all the widths!<br />
        Me.Size = New Size(width, Me.Size.Height) 'set the new size<br />
    End Sub<br />
<br />
<br />
End Class[/code2]<br />
<br />
Here is a quick screenshot of the control in action:<br />
[attachment=2]&lt;!-- ia2 --&gt;changeablelabelconcept.png&lt;!-- ia2 --&gt;[/attachment]<br />
<br />
<br />
Instead of typing out all of the information about this control, I have made a video tutorial that explains it. Watch it here:<br />
[youtube]PcumZmVh4JM[/youtube]<br />
<br />
<span style="font-weight: bold;" class="mycode_b">Download the project here:</span><br />
[attachment=1]&lt;!-- ia1 --&gt;TextBoxChangeControlTut.zip&lt;!-- ia1 --&gt;[/attachment]<br />
<br />
Download only the control resources here:[attachment=0]&lt;!-- ia0 --&gt;ChangableLabel.zip&lt;!-- ia0 --&gt;[/attachment]<br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://bpforums.info/images/attachtypes/image.png" title="PNG Image" border="0" alt=".png" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=106" target="_blank" title="">changeablelabelconcept.png</a> (Size: 45.15 KB / Downloads: 1708)
<!-- end: postbit_attachments_attachment --><br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://bpforums.info/images/attachtypes/zip.png" title="ZIP File" border="0" alt=".zip" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=107" target="_blank" title="">TextBoxChangeControlTut.zip</a> (Size: 72.03 KB / Downloads: 872)
<!-- end: postbit_attachments_attachment --><br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://bpforums.info/images/attachtypes/zip.png" title="ZIP File" border="0" alt=".zip" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=108" target="_blank" title="">ChangableLabel.zip</a> (Size: 4.33 KB / Downloads: 870)
<!-- end: postbit_attachments_attachment -->]]></description>
			<content:encoded><![CDATA[This is more of a control than a code snippet, but I wanted to share my "editable label" control anyway.<br />
<br />
The premise behind this control is the idea that users should be able to view and edit information; however, the ability to edit should remain non-intrusive. This is especially useful for people like on-phone tech-support who often need to view information but very rarely need to edit it. <br />
<br />
The control consists of the following items<br />
-A FlowLayoutPanel<br />
-Two Labels<br />
-A TextBox<br />
<br />
Here is the code behind the control:<br />
[code2=vbnet]Public Class ChangableLabel<br />
    '============================================================================<br />
    'ChangableLabel class created by Brandon Milton (brandonio21)<br />
    'This class was created specifically for a tutorial on the BrandonioProductions YouTube channel<br />
    '     You can find this channel at: &lt;!-- m --&gt;&lt;a class="postlink" href="http://youtube.com/BrandonioProductions"&gt;http://youtube.com/BrandonioProductions&lt;/a&gt;&lt;!-- m --&gt;<br />
    'Discussion of this class is held at BP Forums<br />
    '     A direct link to the thread: &lt;!-- l --&gt;&lt;a class="postlink-local" href="http://bpforums.info/viewtopic.php?f=22&amp;t=745"&gt;viewtopic.php?f=22&amp;t=745&lt;/a&gt;&lt;!-- l --&gt;<br />
    'Feel free to use this class in any way, but please remember to credit the author somewhere in the application<br />
    '=============================================================================<br />
<br />
    Public Property IdentifierText As String<br />
        'This property allows us to change the text of the first label when objectilized (sp?)<br />
        Get<br />
            Return lbl_identifier.Text<br />
        End Get<br />
        Set(value As String)<br />
            lbl_identifier.Text = value<br />
        End Set<br />
    End Property<br />
    Public Property InformationText As String<br />
        'This property allows us to change the text of the second label when objectilized (sp?)<br />
        Get<br />
            Return lbl_information.Text<br />
        End Get<br />
        Set(value As String)<br />
            lbl_information.Text = value<br />
        End Set<br />
    End Property<br />
<br />
    Private Sub lbl_information_MouseDoubleClick(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles lbl_information.MouseDoubleClick<br />
        'Here we want the textbox to appear<br />
        Dim oldLabel As Label = CType(flp_main.Controls.Item(1), Label) 'Save the label<br />
        flp_main.Controls.RemoveAt(1) 'Remove the label from the FlowLayoutPanel (so it can be replaced)<br />
<br />
        Dim txt_information As New TextBox 'Create textbox<br />
        Dim textboxSize As New Size(GetLabelWidth(oldLabel) + 25, txt_information.Size.Height) 'set size to ~ same size as label to avoid awkwardness<br />
        txt_information.Size = textboxSize 'set the size<br />
        txt_information.Text = oldLabel.Text 'set the text as old label text<br />
        AddHandler txt_information.KeyPress, AddressOf txt_information_keypress 'add handler to detect "enter" presses<br />
<br />
        flp_main.Controls.Add(txt_information) 'add the textbox to the FlowLayoutPanel<br />
    End Sub<br />
<br />
    Private Function GetLabelWidth(ByVal label As Label) As Integer<br />
        'This method gets the pixel width of labels<br />
        Dim g As Graphics = label.CreateGraphics() 'create graphix object for label to access info<br />
        Dim fontSize As SizeF 'var to save font sizes<br />
        fontSize = g.MeasureString(label.Text, label.Font) 'save the pixeled size of the label's text<br />
        Return fontSize.Width 'return the object (this is a function, afterall)<br />
    End Function<br />
    Private Sub txt_information_keypress(sender As Object, e As KeyPressEventArgs)<br />
        'this method is used to detect when the enter key is pressed on the textbox, return everything to normal state<br />
        If (e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Enter)) Then<br />
            Dim txt_information As TextBox = CType(sender, TextBox) 'save textbox var<br />
            Dim newLabel As New Label 'create new label<br />
            newLabel.AutoSize = True 'This gave lots of problems; allows for the control to resize with new label<br />
            newLabel.Text = txt_information.Text 'set the labels text to user input<br />
            AddHandler newLabel.MouseDoubleClick, AddressOf lbl_information_MouseDoubleClick<br />
            AddHandler newLabel.TextChanged, AddressOf ResizeControl<br />
            '^Adding handlers to resize the control and to detect double clicks, self-explanatory<br />
<br />
            'now we need to remove the textbox and add the label<br />
            flp_main.Controls.RemoveAt(1)<br />
            flp_main.Controls.Add(newLabel)<br />
<br />
<br />
            ResizeControl() 'resize the entire control to fit the new objects<br />
        End If<br />
    End Sub<br />
<br />
    Private Sub ResizeControl() Handles lbl_identifier.TextChanged, lbl_information.TextChanged<br />
        'this method resizes the control to fit the new objects and to make room for others around it<br />
<br />
        'create vars to hold size information<br />
        Dim identLabel As Label = CType(flp_main.Controls.Item(0), Label) 'save copy of first label<br />
        Dim infoLabel As Label = CType(flp_main.Controls.Item(1), Label) 'save copy of second label<br />
        Dim paddingSpace As Integer = 50<br />
<br />
        Dim width As Integer = GetLabelWidth(identLabel) + GetLabelWidth(infoLabel) + paddingSpace 'add all the widths!<br />
        Me.Size = New Size(width, Me.Size.Height) 'set the new size<br />
    End Sub<br />
<br />
<br />
End Class[/code2]<br />
<br />
Here is a quick screenshot of the control in action:<br />
[attachment=2]&lt;!-- ia2 --&gt;changeablelabelconcept.png&lt;!-- ia2 --&gt;[/attachment]<br />
<br />
<br />
Instead of typing out all of the information about this control, I have made a video tutorial that explains it. Watch it here:<br />
[youtube]PcumZmVh4JM[/youtube]<br />
<br />
<span style="font-weight: bold;" class="mycode_b">Download the project here:</span><br />
[attachment=1]&lt;!-- ia1 --&gt;TextBoxChangeControlTut.zip&lt;!-- ia1 --&gt;[/attachment]<br />
<br />
Download only the control resources here:[attachment=0]&lt;!-- ia0 --&gt;ChangableLabel.zip&lt;!-- ia0 --&gt;[/attachment]<br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://bpforums.info/images/attachtypes/image.png" title="PNG Image" border="0" alt=".png" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=106" target="_blank" title="">changeablelabelconcept.png</a> (Size: 45.15 KB / Downloads: 1708)
<!-- end: postbit_attachments_attachment --><br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://bpforums.info/images/attachtypes/zip.png" title="ZIP File" border="0" alt=".zip" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=107" target="_blank" title="">TextBoxChangeControlTut.zip</a> (Size: 72.03 KB / Downloads: 872)
<!-- end: postbit_attachments_attachment --><br /><!-- start: postbit_attachments_attachment -->
<br /><!-- start: attachment_icon -->
<img src="https://bpforums.info/images/attachtypes/zip.png" title="ZIP File" border="0" alt=".zip" />
<!-- end: attachment_icon -->&nbsp;&nbsp;<a href="attachment.php?aid=108" target="_blank" title="">ChangableLabel.zip</a> (Size: 4.33 KB / Downloads: 870)
<!-- end: postbit_attachments_attachment -->]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Reading and Wrinting XML Files]]></title>
			<link>https://bpforums.info/showthread.php?tid=700</link>
			<pubDate>Sat, 17 Nov 2012 14:35:35 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://bpforums.info/member.php?action=profile&uid=374">Snake_eyes</a>]]></dc:creator>
			<guid isPermaLink="false">https://bpforums.info/showthread.php?tid=700</guid>
			<description><![CDATA[Here is the most simple way to read and write an xml file with attributes and values.<br />
<br />
For the sake of this example let's say we have an application that on form load creates toolstrip butons that when cliked load a web page on a web browser<br />
<br />
First of all let's see the format of the Xml file<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>&lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt;<br />
&lt;root&gt;<br />
&nbsp;&nbsp; &lt;ToolStipButtons&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item Name="btn1" url="www.google.com" btnName ="Google" /&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item name="btn2" url="www.bing.com" btnText="Bing" /&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item name="btn2" url="www.yahoo.com" btnText="Yahoo" /&gt;<br />
&nbsp;&nbsp; &lt;/ToolStripButtons&gt;&nbsp;&nbsp; <br />
&lt;/root&gt;</code></div></div><br />
In order for the code to work we need to import System.Xml<br />
[code2=vbnet]Imports System.Xml[/code2]<br />
<br />
<span style="font-size: 50pt;" class="mycode_size"><span style="font-weight: bold;" class="mycode_b"><span style="text-decoration: underline;" class="mycode_u">Reading the xml file</span></span></span><br />
<br />
Now let's see about reading the values from the xml file and creating the buttons.<br />
[code2=vbnet]Public Sub CreateButons()<br />
        Dim Xml_Doc As New XmlDocument<br />
        Xml_Doc.Load(Application.StartupPath &amp; "/AppSettings.xml")<br />
        Dim xmlNode As XmlNode<br />
        For Each xmlNode In xmlDoc.SelectNodes("/root/ToolStripButtons/item")<br />
            Dim NewBtn As New ToolStripButton With {.Name = node.Attributes("name").Value.ToString, _<br />
                                                    .Tag = node.Attributes("url").Value.ToString, _<br />
                                                    .Text = node.Attributes("btnText").Value.ToString}                                                   }<br />
            AddHandler NewBtn.Click, AddressOf NewBtn_Click<br />
            ToolStrip1.Items.Add(NewBtn)<br />
        Next<br />
    End Sub[/code2]<br />
<br />
After this just create a sub named "NewBtn_Click" to handle the click event of the individual buttons<br />
<br />
<span style="font-weight: bold;" class="mycode_b"><span style="font-size: 50pt;" class="mycode_size"><span style="text-decoration: underline;" class="mycode_u">Writing the xml file</span></span></span><br />
<br />
If changes occured to the ToolStripButtons and we need to save the new values to the xml file then we will use the folowing code:<br />
<br />
[code2=vbnet]Public Sub SaveValues()<br />
<br />
        Dim settings As New XmlWriterSettings<br />
        settings.Indent = True<br />
        settings.NewLineOnAttributes = False<br />
<br />
        Dim Xml_doc As New XmlDocument<br />
        Xml_doc.Load(Application.StartupPath &amp; "\AppSettings.xml")<br />
        Xml_doc.RemoveAll()<br />
<br />
        Dim Writer As XmlWriter = XmlWriter.Create(Application.StartupPath &amp; "\AppSettings.xml", settings)<br />
<br />
        With Writer<br />
            .WriteStartDocument(True)<br />
            .WriteStartElement("root")<br />
            .WriteStartElement("ToolStripButtons")<br />
<br />
            For Each Btn As ToolStripButton In ToolStrip1.Items<br />
                '//Writes the Item Element<br />
                .WriteStartElement("item")<br />
                '// Writes the "Name"  atribute and it's value<br />
                .WriteStartAttribute("name")<br />
                .WriteValue(Btn.Name)<br />
                .WriteEndAttribute()<br />
                '// Writes the "url" atribute and it's value<br />
                .WriteStartAttribute("url")<br />
                .WriteValue(Btn.Tag)<br />
                .WriteEndAttribute()<br />
                '// Writes the "btnText" atribute and it's value<br />
                .WriteStartAttribute("btnText")<br />
                .WriteValue(Btn.Text)<br />
                .WriteEndAttribute()<br />
                '// Writes the end of the item element<br />
                .WriteEndElement()<br />
<br />
            Next<br />
            .WriteEndElement()<br />
            .WriteEndElement()<br />
            .WriteEndDocument()<br />
            .Flush()<br />
            .Close()<br />
        End With<br />
<br />
    End Sub[/code2]<br />
<br />
<br />
Now just simply call the CreateButons() on the Form_Load event and the SaveValues() in the Form_Closing event(or any other sub for that mater, depending on your needs).<br />
<br />
I also recommend using Try/Catch blocks in order to catch any unwanted errors that might occur]]></description>
			<content:encoded><![CDATA[Here is the most simple way to read and write an xml file with attributes and values.<br />
<br />
For the sake of this example let's say we have an application that on form load creates toolstrip butons that when cliked load a web page on a web browser<br />
<br />
First of all let's see the format of the Xml file<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>&lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&gt;<br />
&lt;root&gt;<br />
&nbsp;&nbsp; &lt;ToolStipButtons&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item Name="btn1" url="www.google.com" btnName ="Google" /&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item name="btn2" url="www.bing.com" btnText="Bing" /&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;item name="btn2" url="www.yahoo.com" btnText="Yahoo" /&gt;<br />
&nbsp;&nbsp; &lt;/ToolStripButtons&gt;&nbsp;&nbsp; <br />
&lt;/root&gt;</code></div></div><br />
In order for the code to work we need to import System.Xml<br />
[code2=vbnet]Imports System.Xml[/code2]<br />
<br />
<span style="font-size: 50pt;" class="mycode_size"><span style="font-weight: bold;" class="mycode_b"><span style="text-decoration: underline;" class="mycode_u">Reading the xml file</span></span></span><br />
<br />
Now let's see about reading the values from the xml file and creating the buttons.<br />
[code2=vbnet]Public Sub CreateButons()<br />
        Dim Xml_Doc As New XmlDocument<br />
        Xml_Doc.Load(Application.StartupPath &amp; "/AppSettings.xml")<br />
        Dim xmlNode As XmlNode<br />
        For Each xmlNode In xmlDoc.SelectNodes("/root/ToolStripButtons/item")<br />
            Dim NewBtn As New ToolStripButton With {.Name = node.Attributes("name").Value.ToString, _<br />
                                                    .Tag = node.Attributes("url").Value.ToString, _<br />
                                                    .Text = node.Attributes("btnText").Value.ToString}                                                   }<br />
            AddHandler NewBtn.Click, AddressOf NewBtn_Click<br />
            ToolStrip1.Items.Add(NewBtn)<br />
        Next<br />
    End Sub[/code2]<br />
<br />
After this just create a sub named "NewBtn_Click" to handle the click event of the individual buttons<br />
<br />
<span style="font-weight: bold;" class="mycode_b"><span style="font-size: 50pt;" class="mycode_size"><span style="text-decoration: underline;" class="mycode_u">Writing the xml file</span></span></span><br />
<br />
If changes occured to the ToolStripButtons and we need to save the new values to the xml file then we will use the folowing code:<br />
<br />
[code2=vbnet]Public Sub SaveValues()<br />
<br />
        Dim settings As New XmlWriterSettings<br />
        settings.Indent = True<br />
        settings.NewLineOnAttributes = False<br />
<br />
        Dim Xml_doc As New XmlDocument<br />
        Xml_doc.Load(Application.StartupPath &amp; "\AppSettings.xml")<br />
        Xml_doc.RemoveAll()<br />
<br />
        Dim Writer As XmlWriter = XmlWriter.Create(Application.StartupPath &amp; "\AppSettings.xml", settings)<br />
<br />
        With Writer<br />
            .WriteStartDocument(True)<br />
            .WriteStartElement("root")<br />
            .WriteStartElement("ToolStripButtons")<br />
<br />
            For Each Btn As ToolStripButton In ToolStrip1.Items<br />
                '//Writes the Item Element<br />
                .WriteStartElement("item")<br />
                '// Writes the "Name"  atribute and it's value<br />
                .WriteStartAttribute("name")<br />
                .WriteValue(Btn.Name)<br />
                .WriteEndAttribute()<br />
                '// Writes the "url" atribute and it's value<br />
                .WriteStartAttribute("url")<br />
                .WriteValue(Btn.Tag)<br />
                .WriteEndAttribute()<br />
                '// Writes the "btnText" atribute and it's value<br />
                .WriteStartAttribute("btnText")<br />
                .WriteValue(Btn.Text)<br />
                .WriteEndAttribute()<br />
                '// Writes the end of the item element<br />
                .WriteEndElement()<br />
<br />
            Next<br />
            .WriteEndElement()<br />
            .WriteEndElement()<br />
            .WriteEndDocument()<br />
            .Flush()<br />
            .Close()<br />
        End With<br />
<br />
    End Sub[/code2]<br />
<br />
<br />
Now just simply call the CreateButons() on the Form_Load event and the SaveValues() in the Form_Closing event(or any other sub for that mater, depending on your needs).<br />
<br />
I also recommend using Try/Catch blocks in order to catch any unwanted errors that might occur]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Areo / Glass effect]]></title>
			<link>https://bpforums.info/showthread.php?tid=651</link>
			<pubDate>Wed, 19 Sep 2012 11:20:14 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://bpforums.info/member.php?action=profile&uid=162">brco900033</a>]]></dc:creator>
			<guid isPermaLink="false">https://bpforums.info/showthread.php?tid=651</guid>
			<description><![CDATA[Here is a code to get the Aero/Glass effect on your forms. It only supports Windows 7 and Vista.<br />
<br />
[code2=vbnet]Imports System.Runtime.InteropServices<br />
Public Class Form1<br />
    Declare Auto Function DwmIsCompositionEnabled Lib "dwmapi.dll" Alias "DwmIsCompositionEnabled" (ByRef pfEnabled As Boolean) As Integer<br />
    Declare Auto Function DwmExtendFrameIntoClientArea Lib "dwmapi.dll" Alias "DwmExtendFrameIntoClientArea" (ByVal hWnd As IntPtr, ByRef pMargin As MARGINS) As Integer<br />
    Dim pMargins As New MARGINS With {.Su = -1, .Sinistra = -1, .Destra = -1, .Giu = -1}<br />
<br />
    &lt;StructLayout(LayoutKind.Sequential)&gt; _<br />
    Public Structure MARGINS<br />
        Public Destra As Integer<br />
        Public Sinistra As Integer<br />
        Public Su As Integer<br />
        Public Giu As Integer<br />
    End Structure<br />
<br />
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load<br />
        Dim en As Boolean = False<br />
        DwmIsCompositionEnabled(en)<br />
        If en Then<br />
            DwmExtendFrameIntoClientArea(Me.Handle, pMargins)<br />
        End If<br />
        Me.TransparencyKey = Color.FromKnownColor(KnownColor.ActiveCaption)<br />
        Me.BackColor = Me.TransparencyKey<br />
    End Sub<br />
End Class[/code2]]]></description>
			<content:encoded><![CDATA[Here is a code to get the Aero/Glass effect on your forms. It only supports Windows 7 and Vista.<br />
<br />
[code2=vbnet]Imports System.Runtime.InteropServices<br />
Public Class Form1<br />
    Declare Auto Function DwmIsCompositionEnabled Lib "dwmapi.dll" Alias "DwmIsCompositionEnabled" (ByRef pfEnabled As Boolean) As Integer<br />
    Declare Auto Function DwmExtendFrameIntoClientArea Lib "dwmapi.dll" Alias "DwmExtendFrameIntoClientArea" (ByVal hWnd As IntPtr, ByRef pMargin As MARGINS) As Integer<br />
    Dim pMargins As New MARGINS With {.Su = -1, .Sinistra = -1, .Destra = -1, .Giu = -1}<br />
<br />
    &lt;StructLayout(LayoutKind.Sequential)&gt; _<br />
    Public Structure MARGINS<br />
        Public Destra As Integer<br />
        Public Sinistra As Integer<br />
        Public Su As Integer<br />
        Public Giu As Integer<br />
    End Structure<br />
<br />
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load<br />
        Dim en As Boolean = False<br />
        DwmIsCompositionEnabled(en)<br />
        If en Then<br />
            DwmExtendFrameIntoClientArea(Me.Handle, pMargins)<br />
        End If<br />
        Me.TransparencyKey = Color.FromKnownColor(KnownColor.ActiveCaption)<br />
        Me.BackColor = Me.TransparencyKey<br />
    End Sub<br />
End Class[/code2]]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Generating a Random Color in Visual Basic .NET]]></title>
			<link>https://bpforums.info/showthread.php?tid=633</link>
			<pubDate>Mon, 03 Sep 2012 18:47:32 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://bpforums.info/member.php?action=profile&uid=317">Macatone</a>]]></dc:creator>
			<guid isPermaLink="false">https://bpforums.info/showthread.php?tid=633</guid>
			<description><![CDATA[Here is a helpful code snippit that I converted to Visual Basic .NET from Brandon's post in the Java forum.<br />
<br />
This function returns a color with random red, green, and blue values.<br />
<br />
Pastebin: <a href="http://pastebin.com/aS7hxDu5" target="_blank" rel="noopener" class="mycode_url">http://pastebin.com/aS7hxDu5</a><br />
<br />
[code2=vbnet]'This function returns a color with random red, green, and blue values<br />
<br />
    Function getRandomColor() As Color<br />
<br />
        Dim random As Random = New Random()<br />
        Return Color.FromArgb(random.Next(256), random.Next(256), random.Next(256))<br />
<br />
    End Function[/code2]]]></description>
			<content:encoded><![CDATA[Here is a helpful code snippit that I converted to Visual Basic .NET from Brandon's post in the Java forum.<br />
<br />
This function returns a color with random red, green, and blue values.<br />
<br />
Pastebin: <a href="http://pastebin.com/aS7hxDu5" target="_blank" rel="noopener" class="mycode_url">http://pastebin.com/aS7hxDu5</a><br />
<br />
[code2=vbnet]'This function returns a color with random red, green, and blue values<br />
<br />
    Function getRandomColor() As Color<br />
<br />
        Dim random As Random = New Random()<br />
        Return Color.FromArgb(random.Next(256), random.Next(256), random.Next(256))<br />
<br />
    End Function[/code2]]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Working with Sockets]]></title>
			<link>https://bpforums.info/showthread.php?tid=560</link>
			<pubDate>Thu, 12 Jul 2012 12:45:42 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://bpforums.info/member.php?action=profile&uid=13">xolara</a>]]></dc:creator>
			<guid isPermaLink="false">https://bpforums.info/showthread.php?tid=560</guid>
			<description><![CDATA[Sockets is a way of 2 or more computers comunicating together and i will show you abit about it.<br />
<br />
In the first part or Part 1 you will have<br />
<br />
Server<br />
Client<br />
<br />
The Server can<br />
Accept Connections<br />
Accept Commands<br />
<br />
The Client can<br />
Connect<br />
Send Commands<br />
<br />
in the next part we will make the server able to send back a command to the client this can be used for example in a login. Your client sends the information to the server, The server then checks the information and sends a green light for the client to login<br />
<br />
<br />
<br />
SOURCE CODE FOR PART 1: &lt;!-- m --&gt;&lt;a class="postlink" href="https://dl.dropbox.com/u/12582973/SocketProgrammingPart1.zip"&gt;https://dl.dropbox.com/u/12582973/Socke ... gPart1.zip&lt;/a&gt;&lt;!-- m --&gt;<br />
<br />
EXE DOWNLOADS FOR PART 1:<br />
&lt;!-- m --&gt;&lt;a class="postlink" href="https://dl.dropbox.com/u/12582973/SocketsPart1.zip"&gt;https://dl.dropbox.com/u/12582973/SocketsPart1.zip&lt;/a&gt;&lt;!-- m --&gt;<br />
<br />
How-To:<br />
<br />
1: Unzip<br />
2: run SocketTest.sln<br />
<br />
This will run both the projects<br />
<br />
<br />
Please note this part does not include the disconnect so when you close the client or server it will be non responsive (Just click the close button and it will be fine)]]></description>
			<content:encoded><![CDATA[Sockets is a way of 2 or more computers comunicating together and i will show you abit about it.<br />
<br />
In the first part or Part 1 you will have<br />
<br />
Server<br />
Client<br />
<br />
The Server can<br />
Accept Connections<br />
Accept Commands<br />
<br />
The Client can<br />
Connect<br />
Send Commands<br />
<br />
in the next part we will make the server able to send back a command to the client this can be used for example in a login. Your client sends the information to the server, The server then checks the information and sends a green light for the client to login<br />
<br />
<br />
<br />
SOURCE CODE FOR PART 1: &lt;!-- m --&gt;&lt;a class="postlink" href="https://dl.dropbox.com/u/12582973/SocketProgrammingPart1.zip"&gt;https://dl.dropbox.com/u/12582973/Socke ... gPart1.zip&lt;/a&gt;&lt;!-- m --&gt;<br />
<br />
EXE DOWNLOADS FOR PART 1:<br />
&lt;!-- m --&gt;&lt;a class="postlink" href="https://dl.dropbox.com/u/12582973/SocketsPart1.zip"&gt;https://dl.dropbox.com/u/12582973/SocketsPart1.zip&lt;/a&gt;&lt;!-- m --&gt;<br />
<br />
How-To:<br />
<br />
1: Unzip<br />
2: run SocketTest.sln<br />
<br />
This will run both the projects<br />
<br />
<br />
Please note this part does not include the disconnect so when you close the client or server it will be non responsive (Just click the close button and it will be fine)]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Trimming a label]]></title>
			<link>https://bpforums.info/showthread.php?tid=549</link>
			<pubDate>Fri, 29 Jun 2012 07:42:02 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://bpforums.info/member.php?action=profile&uid=1">brandonio21_phpbb3_import2</a>]]></dc:creator>
			<guid isPermaLink="false">https://bpforums.info/showthread.php?tid=549</guid>
			<description><![CDATA[I was contacted the other day asking to hand over a code snippet that trimmed a label if it was too long, making it display "...". So, I crafted a method that would do so!<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>'This method is intended to trim a label that is too long and replace it with<br />
&nbsp;&nbsp;&nbsp;&nbsp;'dots where there would normally be stuff<br />
&nbsp;&nbsp;&nbsp;&nbsp;'Made by Brandon Milton, http://brandonsoft.com<br />
&nbsp;&nbsp;&nbsp;&nbsp;Public Sub TrimLabel(ByVal label As Label, ByVal MaxCharCount As Integer)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If (label.Text.Length &gt; MaxCharCount) Then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim remaining As Integer = label.Text.Length - MaxCharCount<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;label.Text = label.Text.Remove(MaxCharCount - 4, 4 + remaining)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;label.Text = label.Text &amp; "..."<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br />
&nbsp;&nbsp;&nbsp;&nbsp;End Sub</code></div></div><br />
Usage:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>Dim Label As New Label<br />
Label.Text = "Hello my name is Brandon"<br />
TrimLabel(Label, 10) 'Trims to a max of 10<br />
MsgBox(Label.Text)</code></div></div>With this usage, the output displayed is <span style="font-style: italic;" class="mycode_i">Hello ...</span> which was trimmed from the original "Hello my name is Brandon"<br />
<br />
Pastebin version: &lt;!-- m --&gt;&lt;a class="postlink" href="http://pastebin.com/PPgYrNqm"&gt;http://pastebin.com/PPgYrNqm&lt;/a&gt;&lt;!-- m --&gt;]]></description>
			<content:encoded><![CDATA[I was contacted the other day asking to hand over a code snippet that trimmed a label if it was too long, making it display "...". So, I crafted a method that would do so!<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>'This method is intended to trim a label that is too long and replace it with<br />
&nbsp;&nbsp;&nbsp;&nbsp;'dots where there would normally be stuff<br />
&nbsp;&nbsp;&nbsp;&nbsp;'Made by Brandon Milton, http://brandonsoft.com<br />
&nbsp;&nbsp;&nbsp;&nbsp;Public Sub TrimLabel(ByVal label As Label, ByVal MaxCharCount As Integer)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If (label.Text.Length &gt; MaxCharCount) Then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim remaining As Integer = label.Text.Length - MaxCharCount<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;label.Text = label.Text.Remove(MaxCharCount - 4, 4 + remaining)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;label.Text = label.Text &amp; "..."<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br />
&nbsp;&nbsp;&nbsp;&nbsp;End Sub</code></div></div><br />
Usage:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>Dim Label As New Label<br />
Label.Text = "Hello my name is Brandon"<br />
TrimLabel(Label, 10) 'Trims to a max of 10<br />
MsgBox(Label.Text)</code></div></div>With this usage, the output displayed is <span style="font-style: italic;" class="mycode_i">Hello ...</span> which was trimmed from the original "Hello my name is Brandon"<br />
<br />
Pastebin version: &lt;!-- m --&gt;&lt;a class="postlink" href="http://pastebin.com/PPgYrNqm"&gt;http://pastebin.com/PPgYrNqm&lt;/a&gt;&lt;!-- m --&gt;]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Creating Custom Events]]></title>
			<link>https://bpforums.info/showthread.php?tid=504</link>
			<pubDate>Tue, 03 Apr 2012 20:57:21 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://bpforums.info/member.php?action=profile&uid=1">brandonio21_phpbb3_import2</a>]]></dc:creator>
			<guid isPermaLink="false">https://bpforums.info/showthread.php?tid=504</guid>
			<description><![CDATA[This code snippet was made after hours of work on my project <span style="font-style: italic;" class="mycode_i"><span style="font-weight: bold;" class="mycode_b">QuickClean</span></span><br />
<br />
To make a custom event, the first thing you are going to do is declare the event for global usage in the global declarations section of your class. For example,<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>Public Class Modes<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;Event onModeSwitch()<br />
<br />
'Sample method<br />
 Public Sub New()<br />
&nbsp;&nbsp; Msgbox(":D")<br />
 End Sub<br />
End Class</code></div></div><br />
Then, in order to call this event, you must use the code snippet <span style="font-style: italic;" class="mycode_i">RaiseEvent</span><br />
<br />
So, using our same example:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>Public Class Modes<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;Event onModeSwitch()<br />
<br />
'Sample method<br />
 Public Sub New()<br />
&nbsp;&nbsp; Msgbox(":D")<br />
 End Sub<br />
<br />
'Sample Method to Raise Event<br />
 Public Sub SwitchMode()<br />
&nbsp;&nbsp;RaiseEvent onModeSwitch()<br />
 End Sub<br />
End Class</code></div></div><br />
Now, every time the <span style="font-style: italic;" class="mycode_i">SwitchMode</span> method is called, the event <span style="font-style: italic;" class="mycode_i">onModeSwitch</span> will be called. This event can now be accessed in the code viewer on any new instance of this class.]]></description>
			<content:encoded><![CDATA[This code snippet was made after hours of work on my project <span style="font-style: italic;" class="mycode_i"><span style="font-weight: bold;" class="mycode_b">QuickClean</span></span><br />
<br />
To make a custom event, the first thing you are going to do is declare the event for global usage in the global declarations section of your class. For example,<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>Public Class Modes<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;Event onModeSwitch()<br />
<br />
'Sample method<br />
 Public Sub New()<br />
&nbsp;&nbsp; Msgbox(":D")<br />
 End Sub<br />
End Class</code></div></div><br />
Then, in order to call this event, you must use the code snippet <span style="font-style: italic;" class="mycode_i">RaiseEvent</span><br />
<br />
So, using our same example:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>Public Class Modes<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;Event onModeSwitch()<br />
<br />
'Sample method<br />
 Public Sub New()<br />
&nbsp;&nbsp; Msgbox(":D")<br />
 End Sub<br />
<br />
'Sample Method to Raise Event<br />
 Public Sub SwitchMode()<br />
&nbsp;&nbsp;RaiseEvent onModeSwitch()<br />
 End Sub<br />
End Class</code></div></div><br />
Now, every time the <span style="font-style: italic;" class="mycode_i">SwitchMode</span> method is called, the event <span style="font-style: italic;" class="mycode_i">onModeSwitch</span> will be called. This event can now be accessed in the code viewer on any new instance of this class.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Code within code]]></title>
			<link>https://bpforums.info/showthread.php?tid=445</link>
			<pubDate>Sat, 07 Jan 2012 08:31:10 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://bpforums.info/member.php?action=profile&uid=1">brandonio21_phpbb3_import2</a>]]></dc:creator>
			<guid isPermaLink="false">https://bpforums.info/showthread.php?tid=445</guid>
			<description><![CDATA[Here is just a little tip for you guys, if you ever want to store a snippet of code within a variable, you can use the following syntax.<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>&lt;code&gt;<br />
&lt;/code&gt;</code></div></div><br />
So for example,<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>Dim c = &lt;code&gt;<br />
Messagebox.Show("Hello!")<br />
&lt;/code&gt;</code></div></div><br />
This will actually store the code to display a messagebox with the text of 'Hello' within the c variable. This is very useful if you would like to develop some sort of plugin system for your application.<br />
<br />
I am not too familiar on how executing that variable actually works, but here is a code snippet that shows the execution of code stored within a variable.<br />
&lt;!-- m --&gt;&lt;a class="postlink" href="http://pastebin.com/CKfD7nRz"&gt;http://pastebin.com/CKfD7nRz&lt;/a&gt;&lt;!-- m --&gt;]]></description>
			<content:encoded><![CDATA[Here is just a little tip for you guys, if you ever want to store a snippet of code within a variable, you can use the following syntax.<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>&lt;code&gt;<br />
&lt;/code&gt;</code></div></div><br />
So for example,<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>Dim c = &lt;code&gt;<br />
Messagebox.Show("Hello!")<br />
&lt;/code&gt;</code></div></div><br />
This will actually store the code to display a messagebox with the text of 'Hello' within the c variable. This is very useful if you would like to develop some sort of plugin system for your application.<br />
<br />
I am not too familiar on how executing that variable actually works, but here is a code snippet that shows the execution of code stored within a variable.<br />
&lt;!-- m --&gt;&lt;a class="postlink" href="http://pastebin.com/CKfD7nRz"&gt;http://pastebin.com/CKfD7nRz&lt;/a&gt;&lt;!-- m --&gt;]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Keeping Track of Multiple Things (Alternative to an Array)]]></title>
			<link>https://bpforums.info/showthread.php?tid=431</link>
			<pubDate>Sun, 27 Nov 2011 23:02:55 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://bpforums.info/member.php?action=profile&uid=1">brandonio21_phpbb3_import2</a>]]></dc:creator>
			<guid isPermaLink="false">https://bpforums.info/showthread.php?tid=431</guid>
			<description><![CDATA[I thought that some of you may find this useful, It is the List object in VB.NET, which allows you to hold several things in one object. For example, if you have several strings.<br />
<br />
[code2=vbnet]Dim str1 As String = "Hello"<br />
Dim str2 As String = "My"<br />
Dim str3 As String = "Name"<br />
Dim str4 As String = "Is"<br />
Dim str5 As String = "Brandon"<br />
Dim strList As List(Of String)<br />
strList.Add(str1)<br />
strList.Add(str2)<br />
strList.Add(str3)<br />
strList.Add(str4)<br />
strList.Add(str5)<br />
<br />
Dim total As String = ""<br />
For Each item In strList<br />
total = total + " " + item<br />
Next<br />
Msgbox(total)[/code2]<br />
This code will print out a MessageBox with the text of "Hello My Name Is Brandon "<br />
<br />
Obviously this is not the best use for Lists, but they may come in handy when doing something else, so be sure to play around with them!]]></description>
			<content:encoded><![CDATA[I thought that some of you may find this useful, It is the List object in VB.NET, which allows you to hold several things in one object. For example, if you have several strings.<br />
<br />
[code2=vbnet]Dim str1 As String = "Hello"<br />
Dim str2 As String = "My"<br />
Dim str3 As String = "Name"<br />
Dim str4 As String = "Is"<br />
Dim str5 As String = "Brandon"<br />
Dim strList As List(Of String)<br />
strList.Add(str1)<br />
strList.Add(str2)<br />
strList.Add(str3)<br />
strList.Add(str4)<br />
strList.Add(str5)<br />
<br />
Dim total As String = ""<br />
For Each item In strList<br />
total = total + " " + item<br />
Next<br />
Msgbox(total)[/code2]<br />
This code will print out a MessageBox with the text of "Hello My Name Is Brandon "<br />
<br />
Obviously this is not the best use for Lists, but they may come in handy when doing something else, so be sure to play around with them!]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Integer Arrays!]]></title>
			<link>https://bpforums.info/showthread.php?tid=406</link>
			<pubDate>Mon, 03 Oct 2011 05:12:23 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://bpforums.info/member.php?action=profile&uid=1">brandonio21_phpbb3_import2</a>]]></dc:creator>
			<guid isPermaLink="false">https://bpforums.info/showthread.php?tid=406</guid>
			<description><![CDATA[I recently did a java tutorial on integer arrays, so I thought that I'd post the vb.net version of the code as well!<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>Public Sub Execute()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim arrInt(5) As Integer 'Creates an integer array with 5 slots<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;arrInt(0) = 1 'Assigns a value of 1 to the first slot in the array<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim i As Integer = 0 'Creates an integer, i, and gives the initial value of 0<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Do While i &lt; 5 'While i is 0-4<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;arrInt(i) = i + 1 'Tell the corresponding slot in the array to be equal to i+1, so if i was 3, arrInt(3) would be set to 4<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i = i + 1 'Increase the value of i by 1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Loop<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox(arrInt(0).ToString + " " + arrInt(1).ToString + " " + arrInt(2).ToString + " " + arrInt(3).ToString + " " + arrInt(4).ToString) 'Convert all the array values to strings, and display them in a messagebox<br />
&nbsp;&nbsp;&nbsp;&nbsp;End Sub</code></div></div><br />
After posting this little code snippet, I realized that I never really created a video explaining Arrays in vb.net. Since arrays are extremely useful, I may be doing a tutorial on this soon!]]></description>
			<content:encoded><![CDATA[I recently did a java tutorial on integer arrays, so I thought that I'd post the vb.net version of the code as well!<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>Public Sub Execute()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim arrInt(5) As Integer 'Creates an integer array with 5 slots<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;arrInt(0) = 1 'Assigns a value of 1 to the first slot in the array<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim i As Integer = 0 'Creates an integer, i, and gives the initial value of 0<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Do While i &lt; 5 'While i is 0-4<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;arrInt(i) = i + 1 'Tell the corresponding slot in the array to be equal to i+1, so if i was 3, arrInt(3) would be set to 4<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i = i + 1 'Increase the value of i by 1<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Loop<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox(arrInt(0).ToString + " " + arrInt(1).ToString + " " + arrInt(2).ToString + " " + arrInt(3).ToString + " " + arrInt(4).ToString) 'Convert all the array values to strings, and display them in a messagebox<br />
&nbsp;&nbsp;&nbsp;&nbsp;End Sub</code></div></div><br />
After posting this little code snippet, I realized that I never really created a video explaining Arrays in vb.net. Since arrays are extremely useful, I may be doing a tutorial on this soon!]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Saving and Reading oAuth Tokens with TwitterVB]]></title>
			<link>https://bpforums.info/showthread.php?tid=387</link>
			<pubDate>Wed, 10 Aug 2011 22:57:10 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://bpforums.info/member.php?action=profile&uid=1">brandonio21_phpbb3_import2</a>]]></dc:creator>
			<guid isPermaLink="false">https://bpforums.info/showthread.php?tid=387</guid>
			<description><![CDATA[I have received a request to post a code that would allow the user to save and read the user's Twitter oAuth Tokens, so here it is.<br />
<br />
This is the code that writes the file:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>Public Shared Function getOAuth(ByVal username As String, ByVal PIN As String)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Try<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim writer As New System.IO.StreamWriter(My.Application.Info.DirectoryPath + "/" + username + ".dat")<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim pinIsValid As Boolean = tw.ValidatePIN(PIN)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If pinIsValid = True Then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'PIN is valid, write it<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim oAuth As String = tw.OAuth_Token<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim oAuthSecret As String = tw.OAuth_TokenSecret<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writer.Write(oAuth + "/" + oAuthSecret)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writer.Close()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return "oAuth Information Written!"<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return "Invalid PIN"<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Catch ex As Exception<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Trace.TraceWarning("Error while trying to get oAuth Tokens, " + ex.Message)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return ""<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End Try<br />
&nbsp;&nbsp;&nbsp;&nbsp;End Function</code></div></div>Keep in mind that code also checks to see whether the PIN is valid or not, so you could use this entire code snippet to validate the twitter username.<br />
<br />
This is the code to authenticate the user:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>Public Shared Function Authenticate(ByVal username As String) As Boolean<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Try<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim reader As New System.IO.StreamReader(My.Application.Info.DirectoryPath + "/" + username + ".dat")<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim oAuthToken As String = reader.ReadToEnd.Split("/")(0).ToString<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim oAuthTokenSecret As String = reader.ReadToEnd.Split("/")(1).ToString<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reader.Close()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tw.AuthenticateWith(consumerKey, consumerSecret, oAuthToken, oAuthTokenSecret)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return True<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Catch ex As Exception<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Trace.TraceWarning("There was an error while trying to authenticate, " + ex.Message)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return False<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End Try<br />
&nbsp;&nbsp;&nbsp;&nbsp;End Function</code></div></div><br />
This code might also prove useful.. It checks whether or not an oAuth Token for that username has already been saved.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>Public Shared Function oAuthExists(ByVal username As String) As Boolean<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Try<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If My.Computer.FileSystem.FileExists(My.Application.Info.DirectoryPath + "/" + username + ".dat") Then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim reader As New System.IO.StreamReader(My.Application.Info.DirectoryPath + "/" + username + ".dat")<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If reader.ReadToEnd = "" Then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return False<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return True<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reader.Close()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return False<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Catch ex As Exception<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return False<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End Try<br />
&nbsp;&nbsp;&nbsp;&nbsp;End Function</code></div></div><br />
I hope that this has helped!]]></description>
			<content:encoded><![CDATA[I have received a request to post a code that would allow the user to save and read the user's Twitter oAuth Tokens, so here it is.<br />
<br />
This is the code that writes the file:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>Public Shared Function getOAuth(ByVal username As String, ByVal PIN As String)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Try<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim writer As New System.IO.StreamWriter(My.Application.Info.DirectoryPath + "/" + username + ".dat")<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim pinIsValid As Boolean = tw.ValidatePIN(PIN)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If pinIsValid = True Then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'PIN is valid, write it<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim oAuth As String = tw.OAuth_Token<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim oAuthSecret As String = tw.OAuth_TokenSecret<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writer.Write(oAuth + "/" + oAuthSecret)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;writer.Close()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return "oAuth Information Written!"<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return "Invalid PIN"<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Catch ex As Exception<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Trace.TraceWarning("Error while trying to get oAuth Tokens, " + ex.Message)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return ""<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End Try<br />
&nbsp;&nbsp;&nbsp;&nbsp;End Function</code></div></div>Keep in mind that code also checks to see whether the PIN is valid or not, so you could use this entire code snippet to validate the twitter username.<br />
<br />
This is the code to authenticate the user:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>Public Shared Function Authenticate(ByVal username As String) As Boolean<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Try<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim reader As New System.IO.StreamReader(My.Application.Info.DirectoryPath + "/" + username + ".dat")<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim oAuthToken As String = reader.ReadToEnd.Split("/")(0).ToString<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim oAuthTokenSecret As String = reader.ReadToEnd.Split("/")(1).ToString<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reader.Close()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tw.AuthenticateWith(consumerKey, consumerSecret, oAuthToken, oAuthTokenSecret)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return True<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Catch ex As Exception<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Trace.TraceWarning("There was an error while trying to authenticate, " + ex.Message)<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return False<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End Try<br />
&nbsp;&nbsp;&nbsp;&nbsp;End Function</code></div></div><br />
This code might also prove useful.. It checks whether or not an oAuth Token for that username has already been saved.<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>Public Shared Function oAuthExists(ByVal username As String) As Boolean<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Try<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If My.Computer.FileSystem.FileExists(My.Application.Info.DirectoryPath + "/" + username + ".dat") Then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim reader As New System.IO.StreamReader(My.Application.Info.DirectoryPath + "/" + username + ".dat")<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If reader.ReadToEnd = "" Then<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return False<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return True<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reader.Close()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return False<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Catch ex As Exception<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Return False<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End Try<br />
&nbsp;&nbsp;&nbsp;&nbsp;End Function</code></div></div><br />
I hope that this has helped!]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Improved program trial]]></title>
			<link>https://bpforums.info/showthread.php?tid=381</link>
			<pubDate>Sat, 06 Aug 2011 05:36:53 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://bpforums.info/member.php?action=profile&uid=1">brandonio21_phpbb3_import2</a>]]></dc:creator>
			<guid isPermaLink="false">https://bpforums.info/showthread.php?tid=381</guid>
			<description><![CDATA[A little while ago I posted a video tutorial on how to make your application a 30 day trial. Well, after reviewing that video I realized that the code was long obsolete. So here is a new code.<br />
<br />
[code2=vbnet]'This variable, trialLength is the number of days you want your free trial (or paid) to last.<br />
Dim trialLength As Integer = 7<br />
If My.Settings.startdate.Year = 1 Then<br />
            'Date has not yet been set, set it for today<br />
            My.Settings.startdate = My.Computer.Clock.LocalTime<br />
        Else<br />
            'Date has already been set, check for # days<br />
            Dim ts As New TimeSpan(-trialLength, 0, 0, 0, 0)<br />
            If My.Settings.startdate.Subtract(My.Computer.Clock.LocalTime) &lt;= ts Then<br />
'This part of the code occurs if the trial is finished<br />
                MsgBox("7 Day trial ended!")<br />
            Else<br />
'Trial has not yet ended<br />
                MsgBox("You're good.")<br />
            End If<br />
        End If[/code2]<br />
<br />
So simply adjust the trialLength variable to how many days you want your trial to last, and put this into your form load sub!]]></description>
			<content:encoded><![CDATA[A little while ago I posted a video tutorial on how to make your application a 30 day trial. Well, after reviewing that video I realized that the code was long obsolete. So here is a new code.<br />
<br />
[code2=vbnet]'This variable, trialLength is the number of days you want your free trial (or paid) to last.<br />
Dim trialLength As Integer = 7<br />
If My.Settings.startdate.Year = 1 Then<br />
            'Date has not yet been set, set it for today<br />
            My.Settings.startdate = My.Computer.Clock.LocalTime<br />
        Else<br />
            'Date has already been set, check for # days<br />
            Dim ts As New TimeSpan(-trialLength, 0, 0, 0, 0)<br />
            If My.Settings.startdate.Subtract(My.Computer.Clock.LocalTime) &lt;= ts Then<br />
'This part of the code occurs if the trial is finished<br />
                MsgBox("7 Day trial ended!")<br />
            Else<br />
'Trial has not yet ended<br />
                MsgBox("You're good.")<br />
            End If<br />
        End If[/code2]<br />
<br />
So simply adjust the trialLength variable to how many days you want your trial to last, and put this into your form load sub!]]></content:encoded>
		</item>
	</channel>
</rss>