<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>VB on Lin's Blog</title><link>https://coder.tw/en/tags/vb/</link><description>Recent content in VB on Lin's Blog</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Tue, 26 Jul 2011 12:17:23 +0000</lastBuildDate><atom:link href="https://coder.tw/en/tags/vb/index.xml" rel="self" type="application/rss+xml"/><item><title>How to Compute an MD5 Hash in VB.NET (System.Security.Cryptography)</title><link>https://coder.tw/en/posts/vb-net-md5-system-security-cryptography/</link><pubDate>Tue, 26 Jul 2011 12:17:23 +0000</pubDate><guid>https://coder.tw/en/posts/vb-net-md5-system-security-cryptography/</guid><description>&lt;p&gt;Recently I was writing a password generator and needed to compute an MD5 hash. In PHP I can just call md5() to get an MD5 hash, but I had never actually tried MD5 in VB. I was worried that .NET might not have any MD5 support, in which case I would have to write it myself&amp;hellip;. Orz. Luckily, when I checked MSDN, it turned out to be there. The process was a bit of a hassle, but fortunately MSDN provides a getMD5hash function, so I simply reused it.&lt;/p&gt;</description></item><item><title>How to Read Windows Environment Variables (System Variables) in a .NET Program - VB.NET Example</title><link>https://coder.tw/en/posts/net-windows-environment-variables-vb-net/</link><pubDate>Fri, 11 Feb 2011 09:55:35 +0000</pubDate><guid>https://coder.tw/en/posts/net-windows-environment-variables-vb-net/</guid><description>&lt;p style="text-align: center;"&gt;&lt;a href="https://pub-6c026d2742d14927bfa2d850c31eac91.r2.dev/wp-content/uploads/2011/02/2010-11-07_144258.jpg"&gt;&lt;img class="alignnone size-full wp-image-165" title="2010-11-07_144258" src="https://pub-6c026d2742d14927bfa2d850c31eac91.r2.dev/wp-content/uploads/2011/02/2010-11-07_144258.jpg" alt="" width="394" height="406" /&gt;&lt;/a&gt;&lt;/p&gt;
Anyone who has written CMD knows about environment variables. They let you easily get information that differs from one computer to another, such as the user name. In CMD, using an environment variable is simple: you just write it in the %environment variable name% format. In a .NET program, though, it isn't that simple. You need to use the Environ function.
&lt;h2&gt;</description></item><item><title>DNS Firewall - Block Access to Specific Websites and Quickly Edit DNS Mappings</title><link>https://coder.tw/en/posts/dns-firewall-block-websites-2/</link><pubDate>Fri, 21 Jan 2011 11:46:20 +0000</pubDate><guid>https://coder.tw/en/posts/dns-firewall-block-websites-2/</guid><description>&lt;p style="text-align: center;"&gt;&lt;a href="https://pub-6c026d2742d14927bfa2d850c31eac91.r2.dev/wp-content/uploads/2011/01/2011-01-21_112455.jpg"&gt;&lt;img class="size-full wp-image-4393 aligncenter" title="2011-01-21_112455" src="https://pub-6c026d2742d14927bfa2d850c31eac91.r2.dev/wp-content/uploads/2011/01/2011-01-21_112455.jpg" alt="" width="339" height="413" /&gt;&lt;/a&gt;&lt;/p&gt;
DNS Firewall is a program recently written by a webmaster. Its main function is to block access to certain websites. For example, if you have kids at home and you don't want them visiting adult sites or Facebook, you enter the URLs of those two sites into the program, and then this computer can no longer connect to them! The principle behind DNS Firewall is actually very simple. It modifies the hosts file built into Windows and maps the DNS entries of the blocked sites to 127.0.0.1, which is your own computer, so the browser simply can't reach those sites xD</description></item><item><title>[VB] [C++] Calculating n! (Factorial)</title><link>https://coder.tw/en/posts/vb-c-factorial-n-2/</link><pubDate>Wed, 05 Jan 2011 05:58:10 +0000</pubDate><guid>https://coder.tw/en/posts/vb-c-factorial-n-2/</guid><description>&lt;p&gt;&lt;a href="https://pub-6c026d2742d14927bfa2d850c31eac91.r2.dev/wp-content/uploads/2011/01/2011-01-05_054100.jpg"&gt;&lt;img class="alignnone size-large wp-image-4369" title="2011-01-05_054100" src="https://pub-6c026d2742d14927bfa2d850c31eac91.r2.dev/wp-content/uploads/2011/01/2011-01-05_054100-520x253.jpg" alt="" width="520" height="253" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Calculating the factorial of n is very simple. I wrote this program for permutations and combinations: I wanted a rough idea of how many possible answers there would be, so I wrote an n! function to compute the factorial value. A factorial is 1&lt;em&gt;2&lt;/em&gt;3&amp;hellip;..&lt;em&gt;n. In a permutation of 5 items, the result is at most 5&lt;/em&gt;4&lt;em&gt;3&lt;/em&gt;2*1, which means there are at most 120 possible answers.&lt;/p&gt;
&lt;p&gt;Below, I&amp;rsquo;ve made n! into a Function, with a VB version and a C++ version. People who are just starting to learn loops can use this function to practice how loops work. Also, because I was worried that an integer wouldn&amp;rsquo;t be able to hold the result, I used a string to return the value. When you use this Function, you need to convert the return value to a numeric type first.&lt;/p&gt;
&lt;h2&gt;</description></item><item><title>[VB] Splitting a String into Characters (Mid + For Loop)</title><link>https://coder.tw/en/posts/vb-split-string-mid-for-loop-2/</link><pubDate>Tue, 28 Dec 2010 20:01:36 +0000</pubDate><guid>https://coder.tw/en/posts/vb-split-string-mid-for-loop-2/</guid><description>&lt;p style="text-align: center;"&gt;&lt;a href="https://pub-6c026d2742d14927bfa2d850c31eac91.r2.dev/wp-content/uploads/2010/12/2010-12-28_201330.jpg"&gt;&lt;img class="size-full wp-image-4332 aligncenter" title="2010-12-28_201330" src="https://pub-6c026d2742d14927bfa2d850c31eac91.r2.dev/wp-content/uploads/2010/12/2010-12-28_201330.jpg" alt="" width="312" height="344" /&gt;&lt;/a&gt;&lt;/p&gt;
Splitting a string into characters is actually very simple, but it comes up a lot in ACM problems. For example, permutation and combination problems require you to split a string into characters before doing any calculation. The Caesar cipher also uses this technique. Below I'll demonstrate with VB.NET. Other programming languages can do the same thing, and the principle is identical.</description></item><item><title>[VB.Net] Get File Paths of a Specific Format in a Folder and Store Them in an ArrayList (Easily Adapted to Other .NET Languages)</title><link>https://coder.tw/en/posts/vb-net-get-folder-file-paths-arraylist-2/</link><pubDate>Sun, 07 Nov 2010 15:45:56 +0000</pubDate><guid>https://coder.tw/en/posts/vb-net-get-folder-file-paths-arraylist-2/</guid><description>&lt;p style="text-align: center;"&gt;&lt;a href="https://pub-6c026d2742d14927bfa2d850c31eac91.r2.dev/wp-content/uploads/2010/11/2010-11-07_154306.jpg"&gt;&lt;img class="size-large wp-image-3957 aligncenter" title="2010-11-07_154306" src="https://pub-6c026d2742d14927bfa2d850c31eac91.r2.dev/wp-content/uploads/2010/11/2010-11-07_154306-520x311.jpg" alt="" width="520" height="311" /&gt;&lt;/a&gt;&lt;/p&gt;
Last time, while I was working on the entertainment feature of the new version of Desktop Locker, I needed to automatically get all the music files in its Resources folder. That led me to work out the code below, which collects the file paths of a specific format in a folder into an ArrayList. For example, if you want all the mp3 files in a music folder, you can use this code to do it.</description></item><item><title>How to Access Yahoo! Messenger from Code (Change Status, Log In/Out, etc.) (VB Example)</title><link>https://coder.tw/en/posts/program-yahoo-messenger-status-login-logout-2/</link><pubDate>Sun, 07 Nov 2010 14:39:23 +0000</pubDate><guid>https://coder.tw/en/posts/program-yahoo-messenger-status-login-logout-2/</guid><description>&lt;p style="text-align: center;"&gt;&lt;a href="https://pub-6c026d2742d14927bfa2d850c31eac91.r2.dev/wp-content/uploads/2010/11/2010-11-07_153926.jpg"&gt;&lt;img class="size-large wp-image-3955 aligncenter" title="2010-11-07_153926" src="https://pub-6c026d2742d14927bfa2d850c31eac91.r2.dev/wp-content/uploads/2010/11/2010-11-07_153926-520x292.jpg" alt="" width="520" height="292" /&gt;&lt;/a&gt;&lt;/p&gt;
The day before yesterday, a few classmates got bored and started passing around prank programs that change Yahoo! Messenger statuses. That gave me the inspiration to design an advanced version of this status prank program. Writing a program that changes the status in Yahoo! Messenger is actually not hard, because Yahoo itself provides a COM component that makes it easy to configure the messenger. This COM component is called YahooMessengerLib. As far as I know, it can do the following: change the status, get the current status, and log in or out of Yahoo! Messenger. So let me show you how to use the YahooMessengerLib COM component~</description></item><item><title>Keyboard Scan Code Chart (Not Made by Me)</title><link>https://coder.tw/en/posts/keyboard-scan-code-map/</link><pubDate>Sun, 12 Jul 2009 23:34:46 +0000</pubDate><guid>https://coder.tw/en/posts/keyboard-scan-code-map/</guid><description>&lt;p&gt;Here&amp;rsquo;s a chart to share.&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;re doing keyboard simulation with postmessage, you&amp;rsquo;ll need this.&lt;/p&gt;
&lt;p&gt;I found this on the internet.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://pub-6c026d2742d14927bfa2d850c31eac91.r2.dev/wp-content/uploads/2009/07/scancode.gif"&gt;&lt;img class="alignnone size-full wp-image-1601" title="scancode" src="https://pub-6c026d2742d14927bfa2d850c31eac91.r2.dev/wp-content/uploads/2009/07/scancode.gif" alt="scancode" width="509" height="221" /&gt;&lt;/a&gt;&lt;/p&gt;</description></item><item><title>VB Ctrl+F5 Compile</title><link>https://coder.tw/en/posts/vb-ctrl-f5-compile/</link><pubDate>Sat, 04 Jul 2009 12:58:47 +0000</pubDate><guid>https://coder.tw/en/posts/vb-ctrl-f5-compile/</guid><description>&lt;p&gt;Here&amp;rsquo;s a useful tip to share~&lt;/p&gt;
&lt;p&gt;From now on, it&amp;rsquo;s best to compile your VB programs with the Ctrl+F5 shortcut.&lt;/p&gt;
&lt;p&gt;Because the compiled file is smaller.&lt;/p&gt;
&lt;p&gt;Also, if you compile your program with Ctrl+F5,&lt;/p&gt;
&lt;p&gt;the compiled program is placed in the binRelease folder inside the project folder.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://pub-6c026d2742d14927bfa2d850c31eac91.r2.dev/wp-content/uploads/2009/07/2009-07-04_125607.jpg"&gt;&lt;img class="alignnone size-full wp-image-1526" title="2009-07-04_125607" src="https://pub-6c026d2742d14927bfa2d850c31eac91.r2.dev/wp-content/uploads/2009/07/2009-07-04_125607.jpg" alt="2009-07-04_125607" width="426" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;</description></item><item><title>VB - Resizing an Array with Redim</title><link>https://coder.tw/en/posts/vb-redim-array-resize/</link><pubDate>Thu, 02 Jul 2009 10:25:30 +0000</pubDate><guid>https://coder.tw/en/posts/vb-redim-array-resize/</guid><description>&lt;p&gt;Anyone who has learned VB has surely come across the Dim syntax, right?&lt;/p&gt;
&lt;p&gt;It declares a variable (an array) and tells the computer to set aside a block of space for the program.&lt;/p&gt;
&lt;p&gt;But sometimes you don&amp;rsquo;t know how many items an array will hold.&lt;/p&gt;
&lt;p&gt;So setting its size to something huge is a waste.&lt;/p&gt;
&lt;p&gt;Today&amp;rsquo;s topic, Redim, is a statement that lets you reset an array&amp;rsquo;s size.&lt;/p&gt;</description></item><item><title>Source Code Sharing - HOT SCRIPTS</title><link>https://coder.tw/en/posts/source-code-sharing-hot-scripts/</link><pubDate>Sat, 02 May 2009 03:42:00 +0000</pubDate><guid>https://coder.tw/en/posts/source-code-sharing-hot-scripts/</guid><description>&lt;p&gt; When you&amp;rsquo;re writing code, you often need to look for source code to use as a reference, right?&lt;br/&gt;
Here&amp;rsquo;s a website that is said to be the largest source code sharing site in the world.&lt;br/&gt;
I don&amp;rsquo;t think it&amp;rsquo;s really the largest, but it&amp;rsquo;s definitely among the top two :)&lt;br/&gt;
URL: &lt;a href="http://www.hotscripts.com/"&gt;http://www.hotscripts.com/&lt;/a&gt;&lt;br/&gt;
&lt;br/&gt;
When you enter this website, you&amp;rsquo;ll see the category page.&lt;br/&gt;
The categories are organized by programming language.&lt;br/&gt;
The main ones are PHP, CGI, ASP, Perl, Java Scripts&lt;br/&gt;
.AJAX, C &amp;amp; C++, Ruby On Rails (RoR), Python, and so on, with source code for each.&lt;br/&gt;
You can pick the language you want to use and then browse through it slowly.&lt;br/&gt;
Or you can use the search function in the upper-right corner.&lt;br/&gt;
But don&amp;rsquo;t type Chinese.&lt;br/&gt;
Because this is a foreign website, there isn&amp;rsquo;t much Chinese code.&lt;br/&gt;
You can also search within certain categories,&lt;br/&gt;
or search everything (the one that says All&amp;hellip;&amp;hellip;&amp;hellip;..).&lt;br/&gt;
Just select it from the dropdown menu in the search box.&lt;br/&gt;
&lt;img src="http://nwufiq.bay.livefilestore.com/y1pNsHnQXSOq5V3Hz3O2X4D4KWbr81NSSbiy6cHgqFGULbhfIl864I77Gn5exRpEykxzOtg2M1Xp71NfLDVBIEzh7n2S7o0RrBi/2009-05-02_114949.png" alt=""/&gt;&lt;br/&gt;
&lt;br/&gt;
Once you&amp;rsquo;ve found the program you want, you can take a quick look at its description.&lt;br/&gt;
&lt;img src="http://nwufiq.bay.livefilestore.com/y1pYNUI2Br39E1fDbCbiMIf3RzLwc-aKMbmDBkAiDigeJc2G6DOcklJ4KXCwOCD-0hw5Haj6C94QFvjWAsaRH7s1raYcDHEH74z/2009-05-02_115555.png" alt=""/&gt;&lt;br/&gt;
&lt;br/&gt;
If you want to download it, just click the Download button in the window.&lt;br/&gt;
&lt;img src="http://nwufiq.bay.livefilestore.com/y1p_iIOwTpQqpqMFN1OBhxaDeRbEF8uSS26XxFmS5YrRhCtwblyB0pWntbC8WRxWR7eR9RGdXdVmfGZyufrXFVP2_jYV5CH0Iil/2009-05-02_115711.png" alt=""/&gt;&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
&lt;br/&gt;
One more thing to note: some programs are paid.&lt;br/&gt;
Usually the ones marked with a (Sponsor) badge are paid.&lt;br/&gt;
This website also offers account registration.&lt;br/&gt;
In fact, I never needed to register an account when I used it.&lt;br/&gt;&lt;/p&gt;</description></item><item><title>[VB.NET] Renaming Files with rename</title><link>https://coder.tw/en/posts/filesystemrename-batch-rename-syntax/</link><pubDate>Thu, 23 Apr 2009 10:12:00 +0000</pubDate><guid>https://coder.tw/en/posts/filesystemrename-batch-rename-syntax/</guid><description>&lt;p&gt;Today I&amp;rsquo;m going to show you how to rename a file using a method that VB itself provides.&lt;/p&gt;
&lt;p&gt;Its syntax is:&lt;/p&gt;
&lt;pre lang="vb"&gt;Filesystem.rename(a,b)&lt;/pre&gt;
&lt;p&gt;a is the input file, that is, the file to be renamed.&lt;/p&gt;
&lt;p&gt;b is the output file name.&lt;/p&gt;
&lt;p&gt;Please note that both parameters a and b must be given in full form.&lt;/p&gt;
&lt;p&gt;Suppose you want to rename the file c:123.txt to 456.txt. Then you enter:&lt;/p&gt;
&lt;pre lang="vb"&gt;Filesystem.rename("c:123"."c:456.txt")&lt;/pre&gt;
&lt;p&gt;Be careful! Both of my parameters include the file extension, and both include the drive letter and folder name.&lt;/p&gt;</description></item><item><title>How to Write Functions in VB (Major Error Correction)</title><link>https://coder.tw/en/posts/vb-function-syntax-error-fix/</link><pubDate>Sun, 19 Apr 2009 07:17:00 +0000</pubDate><guid>https://coder.tw/en/posts/vb-function-syntax-error-fix/</guid><description>&lt;p&gt;Today I&amp;rsquo;m going to teach everyone how to write their own functions.&lt;/p&gt;
&lt;p&gt;First, you need to know the syntax for functions. Also, you must place your own functions at the very bottom of the program.&lt;/p&gt;
&lt;pre lang="vb"&gt;Syntax:
Function FunctionName(Byval Parameter As ParameterType,Byval Parameter As ParameterType)
FunctionName = (what the function does)
End Function&lt;/pre&gt;
&lt;p&gt;A quick explanation: you can name the function whatever you like, and you don&amp;rsquo;t need to wrap the name in double quotes.&lt;/p&gt;
&lt;p&gt;Parameters are optional. Whether you need them depends on what the function does. If the function needs to receive values, you have to set them up.&lt;/p&gt;</description></item><item><title>VB Syntax for Showing and Closing Forms</title><link>https://coder.tw/en/posts/vb-call-close-form-syntax/</link><pubDate>Fri, 17 Apr 2009 12:40:00 +0000</pubDate><guid>https://coder.tw/en/posts/vb-call-close-form-syntax/</guid><description>&lt;p&gt;&lt;font size="2"&gt; In VB, if you want to switch to another form, you can use the show() syntax.&lt;br/&gt;
The syntax is as follows:&lt;br/&gt;
FormName.show()&lt;br/&gt;
FormName is the name of the form you want to switch to.&lt;br/&gt;
For example, if you want to switch to a form called form2,&lt;br/&gt;
enter form2.show().&lt;br/&gt;
&lt;br/&gt;
If you want to open a new form and then close the old one, the syntax is:&lt;br/&gt;
FormName.close()&lt;br/&gt;
To close the form itself, enter me.close()     ' means &amp;ldquo;close myself&amp;rdquo;&lt;br/&gt;
This syntax can also be used to close other forms.&lt;br/&gt;
The only condition is that the form you close must belong to your own program (well, obviously~~)&lt;/font&gt;&lt;/p&gt;</description></item><item><title>[VB] Replacing Text with the Replace Function</title><link>https://coder.tw/en/posts/vb-replace-function/</link><pubDate>Fri, 17 Apr 2009 12:19:00 +0000</pubDate><guid>https://coder.tw/en/posts/vb-replace-function/</guid><description>&lt;p&gt;If you want to replace part of a string with something else in VB, you can use the Replace function.&lt;/p&gt;
&lt;p&gt;The syntax is as follows:&lt;/p&gt;
&lt;pre lang="vb"&gt;StringName.replace(A,B)
&lt;/pre&gt;
&lt;p&gt;StringName is the name of the variable where your text is stored.&lt;/p&gt;
&lt;p&gt;For example, say you store 123456 in S1.&lt;/p&gt;
&lt;p&gt;Then you enter S1.replace(A,B)&lt;/p&gt;</description></item><item><title>Keep a Window Always on Top with SetWindowPos</title><link>https://coder.tw/en/posts/vb-keep-window-on-top/</link><pubDate>Sat, 14 Feb 2009 15:04:00 +0000</pubDate><guid>https://coder.tw/en/posts/vb-keep-window-on-top/</guid><description>&lt;p&gt;First, add a Timer control to the program.&lt;/p&gt;
&lt;p&gt;Enable the timer (named timer1).&lt;/p&gt;
&lt;p&gt;Set its interval to 100.&lt;/p&gt;
&lt;p&gt;Then enter the following code (paste it over the existing code, replacing what is already there).&lt;/p&gt;
&lt;pre lang="vb"&gt;Option Strict Off
Option Explicit On
Public Class Form1
Inherits System.Windows.Forms.Form
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
Dim IntR As Object
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.Top = 0
Me.Left = 0
Me.Width = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width
Me.Height = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
IntR = SetWindowPos(Me.Handle.ToInt32, -1, 0, 0, 0, 0, 3)
End Sub
End Class&lt;/pre&gt;</description></item><item><title>VB Keyboard Simulation</title><link>https://coder.tw/en/posts/vb-keyboard-simulation/</link><pubDate>Wed, 26 Nov 2008 10:12:00 +0000</pubDate><guid>https://coder.tw/en/posts/vb-keyboard-simulation/</guid><description>&lt;p&gt;The keyboard is still one of the most important input devices for using a computer. Even in today&amp;rsquo;s mouse-dominated world, many programs still can&amp;rsquo;t do without it. But repetitive, tedious keyboard operations can wear people out, so people came up with the idea of using a program to press keys in their place. That saves a lot of effort, and it is exactly what Keyboard Genie (Anjian Jingling) does. So how can we use VB to write a program with similar functionality? Let&amp;rsquo;s first look at how Windows responds to keyboard events.&lt;/p&gt;</description></item></channel></rss>