<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>

<channel>
	<title>Belajar Visual Basic</title>
	<atom:link href="http://programmervb.blog.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://programmervb.blog.com</link>
	<description>Belajar VB Melalui Source Codenya</description>
	<pubDate>Fri, 01 Aug 2008 08:58:16 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Check For a File</title>
		<link>http://programmervb.blog.com/2008/08/01/check-for-a-file/</link>
		<comments>http://programmervb.blog.com/2008/08/01/check-for-a-file/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 08:58:16 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[<p>Public Function FileExist(asPath as string) as Boolean<br />
If UCase(Dir(asPath))=Ucase(trimPath(asPath)) then<br />
FileExist=true<br />
Else</p>
<p>FileExist=False<br />
End If<br />
End Function</p>
Public Function TrimPath(ByVal asPath as string) as string<br />
<p>if Len(asPath)=0 then Exit Function<br />
Dim x as integer<br />
Do</p>
<br />
x=Instr(asPath,"\")<br />
if x=0 then Exit Do<br />
asPath=Right(asPath,Len(asPath)-x)<br />
Loop<br />
TrimPath=asPath<br />
End Function<br />
<br />
Private sub command1_Click()<br />
if fileExist(Text1.text) then<br />
Label1="YES"<br />
else<br />
Label1="NO"<br />
End if<br />
End Sub<br />
<br />
Private sub form_Load()<br />
End sub<br />
<br />
<br />
]]></description>
			<content:encoded><![CDATA[<div>
<p>Public Function FileExist(asPath as string) as Boolean<br />
If UCase(Dir(asPath))=Ucase(trimPath(asPath)) then<br />
FileExist=true<br />
Else</p>
<p>FileExist=False<br />
End If<br />
End Function</p>
<p>Public Function TrimPath(ByVal asPath as string) as string</p>
<p>if Len(asPath)=0 then Exit Function<br />
Dim x as integer<br />
Do</p>
<p>
x=Instr(asPath,&#8221;\&#8221;)<br />
if x=0 then Exit Do<br />
asPath=Right(asPath,Len(asPath)-x)<br />
Loop<br />
TrimPath=asPath<br />
End Function</p>
<p>Private sub command1_Click()<br />
if fileExist(Text1.text) then<br />
Label1=&#8221;YES&#8221;<br />
else<br />
Label1=&#8221;NO&#8221;<br />
End if<br />
End Sub</p>
<p>Private sub form_Load()<br />
End sub</p>
<p>
</div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://programmervb.blog.com/2008/08/01/check-for-a-file/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Low and Upper Case</title>
		<link>http://programmervb.blog.com/2008/07/01/low-and-upper-case/</link>
		<comments>http://programmervb.blog.com/2008/07/01/low-and-upper-case/#comments</comments>
		<pubDate>Tue, 01 Jul 2008 07:11:50 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[<p>'add 2 command buttons and 1 text</p>
<p>Private Sub Command1_Click()<br />
&#160;&#160;&#160; Text1.Text = CapFirst$(Text1.Text)<br />
End Sub</p>
<p>Private Sub Command2_Click()<br />
&#160;&#160;&#160; Text1.Text = LCase$(Text1.Text)<br />
End Sub</p>
<p>'add 1 module<br />
Declare Function CapFirst$ Lib "CAPFIRST.DLL" Alias "CAPFIRST" (ByVal St$)</p>
<br />
]]></description>
			<content:encoded><![CDATA[<div>
<p>&#8216;add 2 command buttons and 1 text</p>
<p>Private Sub Command1_Click()<br />
&#160;&#160;&#160; Text1.Text = CapFirst$(Text1.Text)<br />
End Sub</p>
<p>Private Sub Command2_Click()<br />
&#160;&#160;&#160; Text1.Text = LCase$(Text1.Text)<br />
End Sub</p>
<p>&#8216;add 1 module<br />
Declare Function CapFirst$ Lib &#8220;CAPFIRST.DLL&#8221; Alias &#8220;CAPFIRST&#8221; (ByVal St$)</p>
<p>
</div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://programmervb.blog.com/2008/07/01/low-and-upper-case/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Show Your IP Address</title>
		<link>http://programmervb.blog.com/2008/07/01/show-your-ip-address/</link>
		<comments>http://programmervb.blog.com/2008/07/01/show-your-ip-address/#comments</comments>
		<pubDate>Tue, 01 Jul 2008 07:10:59 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[<p>Add Microsoft Winsock Control 6.0 component<br />
Insert 1 Textbox<br />
Insert 2 Command Buttons Rename Caption as Display and Clear</p>
<p><br />
Private Sub Command1_Click()<br />
If Text1.Text = "" Then<br />
&#160;&#160;&#160; Command1.Enabled = False<br />
&#160;&#160;&#160; Text1.Text = Winsock1.LocalIP<br />
Else<br />
&#160;&#160;&#160; Command1.Enabled = True<br />
End If<br />
End Sub</p>
<p>Private Sub Command2_Click()<br />
Text1.Text = ""<br />
If Text1.Text = "" Then<br />
&#160;&#160;&#160; Command1.Enabled = True<br />
Else<br />
&#160;&#160;&#160; Command1.Enabled = False<br />
End If<br />
End Sub</p>
<p>Private Sub Form_Load()<br />
Text1.Text = ""<br />
If Text1.Text = "" Then<br />
&#160;&#160;&#160; Command1.Enabled = False<br />
Else<br />
&#160;&#160;&#160; Command1.Enabled = True<br />
End If<br />
Text1.Text = Winsock1.LocalIP<br />
End Sub</p>

]]></description>
			<content:encoded><![CDATA[<div>
<p>Add Microsoft Winsock Control 6.0 component<br />
Insert 1 Textbox<br />
Insert 2 Command Buttons Rename Caption as Display and Clear</p>
<p>
Private Sub Command1_Click()<br />
If Text1.Text = &#8220;&#8221; Then<br />
&#160;&#160;&#160; Command1.Enabled = False<br />
&#160;&#160;&#160; Text1.Text = Winsock1.LocalIP<br />
Else<br />
&#160;&#160;&#160; Command1.Enabled = True<br />
End If<br />
End Sub</p>
<p>Private Sub Command2_Click()<br />
Text1.Text = &#8220;&#8221;<br />
If Text1.Text = &#8220;&#8221; Then<br />
&#160;&#160;&#160; Command1.Enabled = True<br />
Else<br />
&#160;&#160;&#160; Command1.Enabled = False<br />
End If<br />
End Sub</p>
<p>Private Sub Form_Load()<br />
Text1.Text = &#8220;&#8221;<br />
If Text1.Text = &#8220;&#8221; Then<br />
&#160;&#160;&#160; Command1.Enabled = False<br />
Else<br />
&#160;&#160;&#160; Command1.Enabled = True<br />
End If<br />
Text1.Text = Winsock1.LocalIP<br />
End Sub</p>
</div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://programmervb.blog.com/2008/07/01/show-your-ip-address/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Permutasi</title>
		<link>http://programmervb.blog.com/2008/05/17/permutasi/</link>
		<comments>http://programmervb.blog.com/2008/05/17/permutasi/#comments</comments>
		<pubDate>Sat, 17 May 2008 05:05:49 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[<p>Option Explicit</p>
<p>Dim id As Integer<br />
Dim N As Integer<br />
Dim perm() As Integer</p>
<p>Function Engine(i As Integer)<br />
&#160;&#160; Dim t As Integer<br />
&#160;&#160; Dim j As Integer<br />
&#160;&#160;<br />
&#160;&#160; id = id + 1<br />
&#160;&#160; perm(i) = id<br />
&#160;&#160; If (id = N) Then stampaj<br />
&#160;&#160; For j = 1 To N<br />
&#160;&#160;&#160;&#160;&#160; If (perm(j) = 0) Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Engine (j)<br />
&#160;&#160;&#160;&#160;&#160; End If<br />
&#160;&#160; DoEvents<br />
&#160;&#160; Next j<br />
&#160;&#160; id = id - 1<br />
&#160;&#160; perm(i) = 0<br />
End Function</p>
<p>Private Sub cmdClear_Click()<br />
&#160; List1.Clear<br />
End Sub</p>
<p>Private Sub cmdGen_Click()<br />
&#160; If Val(txtLength.Text) &#62; Len(txtChar.Text) Then<br />
&#160;&#160;&#160; MsgBox "Jumlah Permutasi Salah"<br />
&#160;&#160;&#160; Exit Sub<br />
&#160; End If<br />
&#160;&#160;<br />
&#160; If Len(txtChar.Text) = 0 Or (Val(txtLength.Text) = 0) Then Exit Sub<br />
&#160;<br />
&#160; Dim i As Integer<br />
&#160; N = Val(txtLength.Text)<br />
&#160; ReDim perm(N)<br />
&#160; For i = 1 To N<br />
&#160;&#160;&#160;&#160; perm(i) = 0<br />
&#160; Next i<br />
&#160; If ChSave.Value = 1 Then<br />
&#160;&#160;&#160;&#160; MsgBox "Disimpan pada hasil.txt"<br />
&#160;&#160;&#160;&#160; Open App.Path + "\hasil.txt" For Output As #1<br />
&#160; End If<br />
&#160; Engine 0<br />
&#160; If ChSave.Value = 1 Then Close #1<br />
&#160;<br />
End Sub</p>
<p>Sub Form_Load()<br />
&#160;&#160; On Error Resume Next<br />
&#160;&#160; id = -1<br />
&#160;&#160;<br />
End Sub</p>
<p>Sub stampaj()<br />
&#160;&#160; Dim i As Integer<br />
&#160;&#160; Dim result As String<br />
&#160;&#160; result = ""<br />
&#160;&#160; For i = 1 To N<br />
&#160;&#160;&#160;&#160;&#160; result = result &#38; CStr(Mid$(txtChar.Text, perm(i), 1))<br />
&#160;&#160; Next i<br />
&#160;&#160; List1.AddItem result<br />
&#160;&#160; If ChSave.Value = 1 Then Print #1, result<br />
End Sub</p>
<p><br />
&#160;</p>

]]></description>
			<content:encoded><![CDATA[<div>
<p>Option Explicit</p>
<p>Dim id As Integer<br />
Dim N As Integer<br />
Dim perm() As Integer</p>
<p>Function Engine(i As Integer)<br />
&#160;&#160; Dim t As Integer<br />
&#160;&#160; Dim j As Integer<br />
&#160;&#160;<br />
&#160;&#160; id = id + 1<br />
&#160;&#160; perm(i) = id<br />
&#160;&#160; If (id = N) Then stampaj<br />
&#160;&#160; For j = 1 To N<br />
&#160;&#160;&#160;&#160;&#160; If (perm(j) = 0) Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Engine (j)<br />
&#160;&#160;&#160;&#160;&#160; End If<br />
&#160;&#160; DoEvents<br />
&#160;&#160; Next j<br />
&#160;&#160; id = id - 1<br />
&#160;&#160; perm(i) = 0<br />
End Function</p>
<p>Private Sub cmdClear_Click()<br />
&#160; List1.Clear<br />
End Sub</p>
<p>Private Sub cmdGen_Click()<br />
&#160; If Val(txtLength.Text) &gt; Len(txtChar.Text) Then<br />
&#160;&#160;&#160; MsgBox &#8220;Jumlah Permutasi Salah&#8221;<br />
&#160;&#160;&#160; Exit Sub<br />
&#160; End If<br />
&#160;&#160;<br />
&#160; If Len(txtChar.Text) = 0 Or (Val(txtLength.Text) = 0) Then Exit Sub<br />
&#160;<br />
&#160; Dim i As Integer<br />
&#160; N = Val(txtLength.Text)<br />
&#160; ReDim perm(N)<br />
&#160; For i = 1 To N<br />
&#160;&#160;&#160;&#160; perm(i) = 0<br />
&#160; Next i<br />
&#160; If ChSave.Value = 1 Then<br />
&#160;&#160;&#160;&#160; MsgBox &#8220;Disimpan pada hasil.txt&#8221;<br />
&#160;&#160;&#160;&#160; Open App.Path + &#8220;\hasil.txt&#8221; For Output As #1<br />
&#160; End If<br />
&#160; Engine 0<br />
&#160; If ChSave.Value = 1 Then Close #1<br />
&#160;<br />
End Sub</p>
<p>Sub Form_Load()<br />
&#160;&#160; On Error Resume Next<br />
&#160;&#160; id = -1<br />
&#160;&#160;<br />
End Sub</p>
<p>Sub stampaj()<br />
&#160;&#160; Dim i As Integer<br />
&#160;&#160; Dim result As String<br />
&#160;&#160; result = &#8220;&#8221;<br />
&#160;&#160; For i = 1 To N<br />
&#160;&#160;&#160;&#160;&#160; result = result &amp; CStr(Mid$(txtChar.Text, perm(i), 1))<br />
&#160;&#160; Next i<br />
&#160;&#160; List1.AddItem result<br />
&#160;&#160; If ChSave.Value = 1 Then Print #1, result<br />
End Sub</p>
<p>
&#160;</p>
</div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://programmervb.blog.com/2008/05/17/permutasi/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Enkripsi Searah</title>
		<link>http://programmervb.blog.com/2008/05/17/enkripsi-searah/</link>
		<comments>http://programmervb.blog.com/2008/05/17/enkripsi-searah/#comments</comments>
		<pubDate>Sat, 17 May 2008 04:58:18 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[<p>Public Function Hash(ByVal text As String) As String<br />
a = 1<br />
For i = 1 To Len(text)<br />
&#160;&#160;&#160; a = Sqr(a * i * Asc(Mid(text, i, 1))) 'Numeric Hash<br />
Next i<br />
Rnd (-1)<br />
Randomize a 'seed PRNG</p>
<p>For i = 1 To 16<br />
&#160;&#160;&#160; Hash = Hash &#38; Chr(Int(Rnd * 256))<br />
Next i<br />
End Function</p>
<p>Private Sub Form_Load()<br />
&#160; MsgBox Hash("EmZ-2509")&#160;&#160;&#160; 'Yang dihasilkan: ‰°'r¿¾ ©Ì¿ÂX*¤W<br />
&#160; End<br />
End Sub</p>

]]></description>
			<content:encoded><![CDATA[<div>
<p>Public Function Hash(ByVal text As String) As String<br />
a = 1<br />
For i = 1 To Len(text)<br />
&#160;&#160;&#160; a = Sqr(a * i * Asc(Mid(text, i, 1))) &#8216;Numeric Hash<br />
Next i<br />
Rnd (-1)<br />
Randomize a &#8217;seed PRNG</p>
<p>For i = 1 To 16<br />
&#160;&#160;&#160; Hash = Hash &amp; Chr(Int(Rnd * 256))<br />
Next i<br />
End Function</p>
<p>Private Sub Form_Load()<br />
&#160; MsgBox Hash(&#8220;EmZ-2509&#8243;)&#160;&#160;&#160; &#8216;Yang dihasilkan: ‰°&#8217;r¿¾ ©Ì¿ÂX*¤W<br />
&#160; End<br />
End Sub</p>
</div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://programmervb.blog.com/2008/05/17/enkripsi-searah/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Enkripsi</title>
		<link>http://programmervb.blog.com/2008/05/17/enkripsi/</link>
		<comments>http://programmervb.blog.com/2008/05/17/enkripsi/#comments</comments>
		<pubDate>Sat, 17 May 2008 04:55:41 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[<p>Function EncDec(inData As Variant, Optional inPW As Variant = "") As Variant<br />
&#160;&#160;&#160;&#160; On Error Resume Next<br />
&#160;&#160;&#160;&#160; Dim arrSBox(0 To 255) As Integer<br />
&#160;&#160;&#160;&#160; Dim arrPW(0 To 255) As Integer<br />
&#160;&#160;&#160;&#160; Dim Bi As Integer, Bj As Integer<br />
&#160;&#160;&#160;&#160; Dim mKey As Integer<br />
&#160;&#160;&#160;&#160; Dim i As Integer, j As Integer<br />
&#160;&#160;&#160;&#160; Dim x As Integer, y As Integer<br />
&#160;&#160;&#160;&#160; Dim mCode As Byte, mCodeSeries As Variant<br />
&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160; EncDec = ""<br />
&#160;&#160;&#160;&#160; If Trim(inData) = "" Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Exit Function<br />
&#160;&#160;&#160;&#160; End If<br />
&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160; If inPW &#60;&#62; "" Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; j = 1<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; For i = 0 To 255<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; arrPW(i) = Asc(Mid$(inPW, j, 1))<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; j = j + 1<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; If j &#62; Len(inPW) Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; j = 1<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; End If<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Next i<br />
&#160;&#160;&#160;&#160; Else<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; For i = 0 To 255<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; arrPW(i) = 0<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Next i<br />
&#160;&#160;&#160;&#160; End If<br />
&#160;&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160; For i = 0 To 255<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; arrSBox(i) = i<br />
&#160;&#160;&#160;&#160; Next i<br />
&#160;&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160; j = 0<br />
&#160;&#160;&#160;&#160; For i = 0 To 255<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; j = (arrSBox(i) + arrPW(i)) Mod 256<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; x = arrSBox(i)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; arrSBox(i) = arrSBox(j)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; arrSBox(j) = x<br />
&#160;&#160;&#160;&#160; Next i<br />
&#160;&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160; mCodeSeries = ""<br />
&#160;&#160;&#160;&#160; Bi = 0: Bj = 0<br />
&#160;&#160;&#160;&#160; For i = 1 To Len(inData)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Bi = (Bi + 1) Mod 256<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Bj = (Bj + arrSBox(Bi)) Mod 256<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ' Tukar<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; x = arrSBox(Bi)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; arrSBox(Bi) = arrSBox(Bj)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; arrSBox(Bj) = x</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 'siapkan kunci untuk XOR<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; mKey = arrSBox((arrSBox(Bi) + arrSBox(Bj)) Mod 256)</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; 'gunakan operasi XOR<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; mCode = Asc(Mid$(inData, i, 1)) Xor mKey<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; mCodeSeries = mCodeSeries &#38; Chr(mCode)<br />
&#160;&#160;&#160;&#160; Next i<br />
&#160;&#160;&#160;&#160; EncDec = mCodeSeries<br />
End Function</p>
<p>Private Sub Form_Load()<br />
&#160; Dim Encrypt As String, Decrypt As String<br />
&#160;<br />
&#160; Encrypt = EncDec("admin", "win")<br />
&#160; Decrypt = EncDec("™D`­&#62;", "win")<br />
&#160; MsgBox "Hasil enkripsi : " &#38; Encrypt &#38; _<br />
&#160;&#160;&#160; vbCrLf &#38; "Hasil dekripsi : " &#38; Decrypt<br />
&#160; End<br />
End Sub</p>

]]></description>
			<content:encoded><![CDATA[<div>
<p>Function EncDec(inData As Variant, Optional inPW As Variant = &#8220;&#8221;) As Variant<br />
&#160;&#160;&#160;&#160; On Error Resume Next<br />
&#160;&#160;&#160;&#160; Dim arrSBox(0 To 255) As Integer<br />
&#160;&#160;&#160;&#160; Dim arrPW(0 To 255) As Integer<br />
&#160;&#160;&#160;&#160; Dim Bi As Integer, Bj As Integer<br />
&#160;&#160;&#160;&#160; Dim mKey As Integer<br />
&#160;&#160;&#160;&#160; Dim i As Integer, j As Integer<br />
&#160;&#160;&#160;&#160; Dim x As Integer, y As Integer<br />
&#160;&#160;&#160;&#160; Dim mCode As Byte, mCodeSeries As Variant<br />
&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160; EncDec = &#8220;&#8221;<br />
&#160;&#160;&#160;&#160; If Trim(inData) = &#8220;&#8221; Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Exit Function<br />
&#160;&#160;&#160;&#160; End If<br />
&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160; If inPW &lt;&gt; &#8220;&#8221; Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; j = 1<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; For i = 0 To 255<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; arrPW(i) = Asc(Mid$(inPW, j, 1))<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; j = j + 1<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; If j &gt; Len(inPW) Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; j = 1<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; End If<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Next i<br />
&#160;&#160;&#160;&#160; Else<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; For i = 0 To 255<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; arrPW(i) = 0<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Next i<br />
&#160;&#160;&#160;&#160; End If<br />
&#160;&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160; For i = 0 To 255<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; arrSBox(i) = i<br />
&#160;&#160;&#160;&#160; Next i<br />
&#160;&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160; j = 0<br />
&#160;&#160;&#160;&#160; For i = 0 To 255<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; j = (arrSBox(i) + arrPW(i)) Mod 256<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; x = arrSBox(i)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; arrSBox(i) = arrSBox(j)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; arrSBox(j) = x<br />
&#160;&#160;&#160;&#160; Next i<br />
&#160;&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160; mCodeSeries = &#8220;&#8221;<br />
&#160;&#160;&#160;&#160; Bi = 0: Bj = 0<br />
&#160;&#160;&#160;&#160; For i = 1 To Len(inData)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Bi = (Bi + 1) Mod 256<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Bj = (Bj + arrSBox(Bi)) Mod 256<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8216; Tukar<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; x = arrSBox(Bi)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; arrSBox(Bi) = arrSBox(Bj)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; arrSBox(Bj) = x</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8217;siapkan kunci untuk XOR<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; mKey = arrSBox((arrSBox(Bi) + arrSBox(Bj)) Mod 256)</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8216;gunakan operasi XOR<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; mCode = Asc(Mid$(inData, i, 1)) Xor mKey<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; mCodeSeries = mCodeSeries &amp; Chr(mCode)<br />
&#160;&#160;&#160;&#160; Next i<br />
&#160;&#160;&#160;&#160; EncDec = mCodeSeries<br />
End Function</p>
<p>Private Sub Form_Load()<br />
&#160; Dim Encrypt As String, Decrypt As String<br />
&#160;<br />
&#160; Encrypt = EncDec(&#8220;admin&#8221;, &#8220;win&#8221;)<br />
&#160; Decrypt = EncDec(&#8220;™D`­&gt;&#8221;, &#8220;win&#8221;)<br />
&#160; MsgBox &#8220;Hasil enkripsi : &#8221; &amp; Encrypt &amp; _<br />
&#160;&#160;&#160; vbCrLf &amp; &#8220;Hasil dekripsi : &#8221; &amp; Decrypt<br />
&#160; End<br />
End Sub</p>
</div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://programmervb.blog.com/2008/05/17/enkripsi/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Menu Pop Up</title>
		<link>http://programmervb.blog.com/2008/05/14/menu-pop-up/</link>
		<comments>http://programmervb.blog.com/2008/05/14/menu-pop-up/#comments</comments>
		<pubDate>Wed, 14 May 2008 05:53:04 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[<p>Option Explicit</p>
<p>Private Declare Function SendMessage Lib "user32" Alias _<br />
&#160;&#160; "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _<br />
&#160;&#160;&#160; ByVal wParam As Long, lParam As Any) As Long</p>
<p>Private Const LB_GETITEMRECT = &#38;H198<br />
Private Const LB_ERR = (-1)</p>
<p>Private Type RECT<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; Left As Long<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; Top As Long<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; Right As Long<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; Bottom As Long<br />
End Type</p>
<p>Public Function GetRClickedItem(MyList As Control, _<br />
&#160;&#160; X As Single, Y As Single) As Long</p>
<p>&#160; 'PURPOSE: Determine which item was right clicked in a list<br />
&#160; 'box, from the list_box's mouse down event.&#160; YOU MUST CALL THIS<br />
&#160; 'FROM THE MOUSEDOWN EVENT, PASSING THE X AND Y VALUES FROM THAT<br />
&#160; 'EVENT TO THIS FUNCTION</p>
<p>&#160;&#160;&#160; 'MYLIST: ListBox Control<br />
&#160;&#160;&#160; 'X, Y: X and Y position from MyList_MouseDown</p>
<p>&#160;&#160;&#160; 'RETURNS:&#160; ListIndex of selected item, or -1 if<br />
&#160;&#160;&#160; 'a) There is no selected item, or b) an error occurs.</p>
<p>&#160;&#160;&#160; Dim clickX As Long, clickY As Long<br />
&#160;&#160;&#160; Dim lRet As Long<br />
&#160;&#160;&#160; Dim CurRect As RECT<br />
&#160;&#160;&#160; Dim l As Long</p>
<p>&#160;&#160;&#160; 'Control must be a listbox<br />
&#160;&#160;&#160; If Not TypeOf MyList Is ListBox Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; GetRClickedItem = LB_ERR<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; Exit Function<br />
&#160;&#160;&#160; End If</p>
<p>&#160;&#160;&#160; 'get x and y in pixels<br />
&#160;&#160;&#160; clickX = X Screen.TwipsPerPixelX<br />
&#160;&#160;&#160; clickY = Y Screen.TwipsPerPixelY</p>
<p>&#160;&#160;&#160; 'Check all items in the list to see if it was clicked on<br />
&#160;&#160;&#160; For l = 0 To MyList.ListCount - 1</p>
<p>&#160;&#160;&#160;&#160;&#160; 'get current selection as rectangle<br />
&#160;&#160;&#160;&#160;&#160; lRet = SendMessage(MyList.hwnd, LB_GETITEMRECT, l, CurRect)</p>
<p>&#160;&#160;&#160;&#160;&#160; 'If the position of the click is in the this list item<br />
&#160;&#160;&#160;&#160;&#160;&#160; 'then that's&#160; our Item</p>
<p>&#160;&#160;&#160;&#160; If (clickX &#62;= CurRect.Left) And (clickX &#60;= CurRect.Right) _<br />
&#160;&#160;&#160;&#160;&#160;&#160; And (clickY &#62;= CurRect.Top) And _<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; (clickY &#60;= CurRect.Bottom) Then</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; GetRClickedItem = l<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Exit Function<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; End If<br />
&#160;&#160;&#160; Next l<br />
End Function</p>
<p>Private Sub Form_Load()<br />
&#160; List1.AddItem "Merah"<br />
&#160; List1.AddItem "Kuning"<br />
&#160; List1.AddItem "Hijau"<br />
&#160; mnuPopUp.Visible = False<br />
End Sub</p>
<p>Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)<br />
Dim lItem As Long</p>
<p>If Button = vbRightButton Then<br />
&#160;&#160;&#160; lItem = GetRClickedItem(List1, X, Y)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; If lItem &#60;&#62; -1 Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; List1.ListIndex = lItem<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; PopupMenu mnuPopUp<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; End If<br />
End If</p>
<p>End Sub</p>
<p><br />
&#160;</p>

]]></description>
			<content:encoded><![CDATA[<div>
<p>Option Explicit</p>
<p>Private Declare Function SendMessage Lib &#8220;user32&#8243; Alias _<br />
&#160;&#160; &#8220;SendMessageA&#8221; (ByVal hwnd As Long, ByVal wMsg As Long, _<br />
&#160;&#160;&#160; ByVal wParam As Long, lParam As Any) As Long</p>
<p>Private Const LB_GETITEMRECT = &amp;H198<br />
Private Const LB_ERR = (-1)</p>
<p>Private Type RECT<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; Left As Long<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; Top As Long<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; Right As Long<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; Bottom As Long<br />
End Type</p>
<p>Public Function GetRClickedItem(MyList As Control, _<br />
&#160;&#160; X As Single, Y As Single) As Long</p>
<p>&#160; &#8216;PURPOSE: Determine which item was right clicked in a list<br />
&#160; &#8216;box, from the list_box&#8217;s mouse down event.&#160; YOU MUST CALL THIS<br />
&#160; &#8216;FROM THE MOUSEDOWN EVENT, PASSING THE X AND Y VALUES FROM THAT<br />
&#160; &#8216;EVENT TO THIS FUNCTION</p>
<p>&#160;&#160;&#160; &#8216;MYLIST: ListBox Control<br />
&#160;&#160;&#160; &#8216;X, Y: X and Y position from MyList_MouseDown</p>
<p>&#160;&#160;&#160; &#8216;RETURNS:&#160; ListIndex of selected item, or -1 if<br />
&#160;&#160;&#160; &#8216;a) There is no selected item, or b) an error occurs.</p>
<p>&#160;&#160;&#160; Dim clickX As Long, clickY As Long<br />
&#160;&#160;&#160; Dim lRet As Long<br />
&#160;&#160;&#160; Dim CurRect As RECT<br />
&#160;&#160;&#160; Dim l As Long</p>
<p>&#160;&#160;&#160; &#8216;Control must be a listbox<br />
&#160;&#160;&#160; If Not TypeOf MyList Is ListBox Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; GetRClickedItem = LB_ERR<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; Exit Function<br />
&#160;&#160;&#160; End If</p>
<p>&#160;&#160;&#160; &#8216;get x and y in pixels<br />
&#160;&#160;&#160; clickX = X Screen.TwipsPerPixelX<br />
&#160;&#160;&#160; clickY = Y Screen.TwipsPerPixelY</p>
<p>&#160;&#160;&#160; &#8216;Check all items in the list to see if it was clicked on<br />
&#160;&#160;&#160; For l = 0 To MyList.ListCount - 1</p>
<p>&#160;&#160;&#160;&#160;&#160; &#8216;get current selection as rectangle<br />
&#160;&#160;&#160;&#160;&#160; lRet = SendMessage(MyList.hwnd, LB_GETITEMRECT, l, CurRect)</p>
<p>&#160;&#160;&#160;&#160;&#160; &#8216;If the position of the click is in the this list item<br />
&#160;&#160;&#160;&#160;&#160;&#160; &#8216;then that&#8217;s&#160; our Item</p>
<p>&#160;&#160;&#160;&#160; If (clickX &gt;= CurRect.Left) And (clickX &lt;= CurRect.Right) _<br />
&#160;&#160;&#160;&#160;&#160;&#160; And (clickY &gt;= CurRect.Top) And _<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; (clickY &lt;= CurRect.Bottom) Then</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; GetRClickedItem = l<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Exit Function<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; End If<br />
&#160;&#160;&#160; Next l<br />
End Function</p>
<p>Private Sub Form_Load()<br />
&#160; List1.AddItem &#8220;Merah&#8221;<br />
&#160; List1.AddItem &#8220;Kuning&#8221;<br />
&#160; List1.AddItem &#8220;Hijau&#8221;<br />
&#160; mnuPopUp.Visible = False<br />
End Sub</p>
<p>Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)<br />
Dim lItem As Long</p>
<p>If Button = vbRightButton Then<br />
&#160;&#160;&#160; lItem = GetRClickedItem(List1, X, Y)<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; If lItem &lt;&gt; -1 Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; List1.ListIndex = lItem<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; PopupMenu mnuPopUp<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160; End If<br />
End If</p>
<p>End Sub</p>
<p>
&#160;</p>
</div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://programmervb.blog.com/2008/05/14/menu-pop-up/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Load Picture</title>
		<link>http://programmervb.blog.com/2008/05/14/load-picture/</link>
		<comments>http://programmervb.blog.com/2008/05/14/load-picture/#comments</comments>
		<pubDate>Wed, 14 May 2008 04:28:16 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[<p>Private Sub Command1_Click()<br />
With Me.CommonDialog1<br />
.DialogTitle = "Ambil Gambar"<br />
.Filter = "JPEG&#124;*.jpg"<br />
.ShowOpen</p>
<p>If .FileName &#60;&#62; "" Then<br />
Set Me.Picture1.Picture = Nothing<br />
Me.Picture1.Picture = LoadPicture(.FileName)<br />
End If<br />
End With<br />
End Sub</p>
<p>'Private Sub Form_Load()<br />
'Me.Picture1.Picture = LoadPicture("D:\gbr_motor\bikes_honda_01.jpg")<br />
'End Sub</p>
<br />
]]></description>
			<content:encoded><![CDATA[<div>
<p>Private Sub Command1_Click()<br />
With Me.CommonDialog1<br />
.DialogTitle = &#8220;Ambil Gambar&#8221;<br />
.Filter = &#8220;JPEG|*.jpg&#8221;<br />
.ShowOpen</p>
<p>If .FileName &lt;&gt; &#8220;&#8221; Then<br />
Set Me.Picture1.Picture = Nothing<br />
Me.Picture1.Picture = LoadPicture(.FileName)<br />
End If<br />
End With<br />
End Sub</p>
<p>&#8216;Private Sub Form_Load()<br />
&#8216;Me.Picture1.Picture = LoadPicture(&#8220;D:\gbr_motor\bikes_honda_01.jpg&#8221;)<br />
&#8216;End Sub</p>
<p>
</div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://programmervb.blog.com/2008/05/14/load-picture/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Sleep With Visual Basic</title>
		<link>http://programmervb.blog.com/2008/05/09/sleep-with-visual-basic/</link>
		<comments>http://programmervb.blog.com/2008/05/09/sleep-with-visual-basic/#comments</comments>
		<pubDate>Fri, 09 May 2008 08:18:13 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[<p>Option Explicit</p>
<p>Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)</p>
<p>Private Sub Form_Click()<br />
&#160;&#160; Me.Caption = "Sleeping"<br />
&#160;&#160; Call Sleep(20000)<br />
&#160;&#160; Me.Caption = "Awake"<br />
End Sub</p>
<p>Private Sub Label1_Click()<br />
&#160;&#160; Me.Caption = "Sleeping"<br />
&#160;&#160; Call Sleep(20000)<br />
&#160;&#160; Me.Caption = "Awake"<br />
End Sub</p>

]]></description>
			<content:encoded><![CDATA[<div>
<p>Option Explicit</p>
<p>Private Declare Sub Sleep Lib &#8220;kernel32&#8243; (ByVal dwMilliseconds As Long)</p>
<p>Private Sub Form_Click()<br />
&#160;&#160; Me.Caption = &#8220;Sleeping&#8221;<br />
&#160;&#160; Call Sleep(20000)<br />
&#160;&#160; Me.Caption = &#8220;Awake&#8221;<br />
End Sub</p>
<p>Private Sub Label1_Click()<br />
&#160;&#160; Me.Caption = &#8220;Sleeping&#8221;<br />
&#160;&#160; Call Sleep(20000)<br />
&#160;&#160; Me.Caption = &#8220;Awake&#8221;<br />
End Sub</p>
</div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://programmervb.blog.com/2008/05/09/sleep-with-visual-basic/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Find Something</title>
		<link>http://programmervb.blog.com/2008/05/09/find-something/</link>
		<comments>http://programmervb.blog.com/2008/05/09/find-something/#comments</comments>
		<pubDate>Fri, 09 May 2008 07:27:08 +0000</pubDate>
		<dc:creator>Administrator</dc:creator>
		
		<guid isPermaLink="false"></guid>
		<description><![CDATA[<p><strong><u>Form</u></strong><br />
<br />
<br />
Option Explicit</p>
<p>Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long</p>
<p>Private Sub cmdActivate_Click()<br />
&#160;&#160; Dim nRet As Long<br />
&#160;&#160; Dim Title As String</p>
<p>&#160;&#160; nRet = AppActivatePartial(Trim(txtTitle.Text), _<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Val(frmMethod.Tag), CBool(chkCase.Value))<br />
&#160;&#160; If nRet Then<br />
&#160;&#160;&#160;&#160;&#160; lblResults.Caption = "Found: &#38;&#38;H" &#38; Hex$(nRet)<br />
&#160;&#160;&#160;&#160;&#160; Title = Space$(256)<br />
&#160;&#160;&#160;&#160;&#160; nRet = GetWindowText(nRet, Title, Len(Title))<br />
&#160;&#160;&#160;&#160;&#160; If nRet Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; lblResults.Caption = lblResults.Caption &#38; _<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ", """ &#38; Left$(Title, nRet) &#38; """"<br />
&#160;&#160;&#160;&#160;&#160; End If<br />
&#160;&#160; Else<br />
&#160;&#160;&#160;&#160;&#160; lblResults.Caption = "Search Failed"<br />
&#160;&#160; End If<br />
End Sub</p>
<p>Private Sub Form_Load()</p>
<p>&#160;&#160; txtTitle.Text = ""<br />
&#160;&#160; lblResults.Caption = ""<br />
&#160;&#160; optMethod(0).Value = True<br />
End Sub</p>
<p>Private Sub optMethod_Click(Index As Integer)</p>
<p><br />
&#160;&#160; frmMethod.Tag = Index<br />
End Sub<br />
<br />
<br />
<strong><u>Module</u></strong><br />
<br />
<br />
Option Explicit</p>
<p><br />
Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long<br />
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long<br />
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long<br />
Private Declare Function IsIconic Lib "user32" (ByVal hWnd As Long) As Long<br />
Private Declare Function IsWindowVisible Lib "user32" (ByVal hWnd As Long) As Long<br />
Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long<br />
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As Long) As Long</p>
<p><br />
Private Const SW_RESTORE = 9</p>
<p>Private m_hWnd As Long<br />
Private m_Method As FindWindowPartialTypes<br />
Private m_CaseSens As Boolean<br />
Private m_Visible As Boolean<br />
Private m_AppTitle As String</p>
<p>Public Enum FindWindowPartialTypes<br />
&#160;&#160; FwpStartsWith = 0<br />
&#160;&#160; FwpContains = 1<br />
&#160;&#160; FwpMatches = 2<br />
End Enum</p>
<p>Public Function AppActivatePartial(AppTitle As String, Optional Method As FindWindowPartialTypes = FwpStartsWith, Optional CaseSensitive As Boolean = False) As Long<br />
&#160;&#160; Dim hWndApp As Long<br />
&#160;<br />
&#160;&#160; hWndApp = FindWindowPartial(AppTitle, Method, CaseSensitive, True)<br />
&#160;&#160; If hWndApp Then<br />
&#160;&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160;&#160; If IsIconic(hWndApp) Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Call ShowWindow(hWndApp, SW_RESTORE)<br />
&#160;&#160;&#160;&#160;&#160; End If<br />
&#160;&#160;&#160;&#160;&#160; Call SetForegroundWindow(hWndApp)<br />
&#160;&#160;&#160;&#160;&#160; AppActivatePartial = hWndApp<br />
&#160;&#160; End If<br />
End Function</p>
<p>Public Function FindWindowPartial(AppTitle As String, _<br />
&#160;&#160; Optional Method As FindWindowPartialTypes = FwpStartsWith, _<br />
&#160;&#160; Optional CaseSensitive As Boolean = False, _<br />
&#160;&#160; Optional MustBeVisible As Boolean = False) As Long<br />
&#160;&#160;<br />
&#160;&#160; m_hWnd = 0<br />
&#160;&#160; m_Method = Method<br />
&#160;&#160; m_CaseSens = CaseSensitive<br />
&#160;&#160; m_AppTitle = AppTitle<br />
&#160;<br />
&#160;&#160; If m_CaseSens = False Then<br />
&#160;&#160;&#160;&#160;&#160; m_AppTitle = UCase$(m_AppTitle)<br />
&#160;&#160; End If<br />
&#160;<br />
&#160;&#160; Call EnumWindows(AddressOf EnumWindowsProc, MustBeVisible)<br />
&#160;&#160; FindWindowPartial = m_hWnd<br />
End Function</p>
<p>Private Function EnumWindowsProc(ByVal hWnd As Long, ByVal lParam As Long) As Long<br />
&#160;&#160; Static WindowText As String<br />
&#160;&#160; Static nRet As Long</p>
<p>&#160;&#160; If lParam Then<br />
&#160;&#160;&#160;&#160;&#160; If IsWindowVisible(hWnd) = False Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; EnumWindowsProc = True<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Exit Function<br />
&#160;&#160;&#160;&#160;&#160; End If<br />
&#160;&#160; End If</p>
<p>&#160;&#160; WindowText = Space$(256)<br />
&#160;&#160; nRet = GetWindowText(hWnd, WindowText, Len(WindowText))<br />
&#160;&#160; If nRet Then<br />
&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160;&#160; WindowText = Left$(WindowText, nRet)<br />
&#160;&#160;&#160;&#160;&#160; If m_CaseSens = False Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; WindowText = UCase$(WindowText)<br />
&#160;&#160;&#160;&#160;&#160; End If<br />
&#160;&#160;<br />
&#160;&#160;&#160;&#160;&#160; Select Case m_Method<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Case FwpStartsWith<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; If InStr(WindowText, m_AppTitle) = 1 Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; m_hWnd = hWnd<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; End If<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Case FwpContains<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; If InStr(WindowText, m_AppTitle) &#60;&#62; 0 Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; m_hWnd = hWnd<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; End If<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Case FwpMatches<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; If WindowText = m_AppTitle Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; m_hWnd = hWnd<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; End If<br />
&#160;&#160;&#160;&#160;&#160; End Select<br />
&#160;&#160; End If<br />
&#160;<br />
&#160;&#160; EnumWindowsProc = (m_hWnd = 0)<br />
End Function</p>
<br />
]]></description>
			<content:encoded><![CDATA[<div>
<p><strong><u>Form</u></strong></p>
<p>
Option Explicit</p>
<p>Private Declare Function GetWindowText Lib &#8220;user32&#8243; Alias &#8220;GetWindowTextA&#8221; (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long</p>
<p>Private Sub cmdActivate_Click()<br />
&#160;&#160; Dim nRet As Long<br />
&#160;&#160; Dim Title As String</p>
<p>&#160;&#160; nRet = AppActivatePartial(Trim(txtTitle.Text), _<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Val(frmMethod.Tag), CBool(chkCase.Value))<br />
&#160;&#160; If nRet Then<br />
&#160;&#160;&#160;&#160;&#160; lblResults.Caption = &#8220;Found: &amp;&amp;H&#8221; &amp; Hex$(nRet)<br />
&#160;&#160;&#160;&#160;&#160; Title = Space$(256)<br />
&#160;&#160;&#160;&#160;&#160; nRet = GetWindowText(nRet, Title, Len(Title))<br />
&#160;&#160;&#160;&#160;&#160; If nRet Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; lblResults.Caption = lblResults.Caption &amp; _<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#8220;, &#8220;&#8221;" &amp; Left$(Title, nRet) &amp; &#8220;&#8221;"&#8221;<br />
&#160;&#160;&#160;&#160;&#160; End If<br />
&#160;&#160; Else<br />
&#160;&#160;&#160;&#160;&#160; lblResults.Caption = &#8220;Search Failed&#8221;<br />
&#160;&#160; End If<br />
End Sub</p>
<p>Private Sub Form_Load()</p>
<p>&#160;&#160; txtTitle.Text = &#8220;&#8221;<br />
&#160;&#160; lblResults.Caption = &#8220;&#8221;<br />
&#160;&#160; optMethod(0).Value = True<br />
End Sub</p>
<p>Private Sub optMethod_Click(Index As Integer)</p>
<p>
&#160;&#160; frmMethod.Tag = Index<br />
End Sub</p>
<p>
<strong><u>Module</u></strong></p>
<p>
Option Explicit</p>
<p>
Private Declare Function EnumWindows Lib &#8220;user32&#8243; (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long<br />
Private Declare Function GetClassName Lib &#8220;user32&#8243; Alias &#8220;GetClassNameA&#8221; (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long<br />
Private Declare Function GetWindowText Lib &#8220;user32&#8243; Alias &#8220;GetWindowTextA&#8221; (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long<br />
Private Declare Function IsIconic Lib &#8220;user32&#8243; (ByVal hWnd As Long) As Long<br />
Private Declare Function IsWindowVisible Lib &#8220;user32&#8243; (ByVal hWnd As Long) As Long<br />
Private Declare Function ShowWindow Lib &#8220;user32&#8243; (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long<br />
Private Declare Function SetForegroundWindow Lib &#8220;user32&#8243; (ByVal hWnd As Long) As Long</p>
<p>
Private Const SW_RESTORE = 9</p>
<p>Private m_hWnd As Long<br />
Private m_Method As FindWindowPartialTypes<br />
Private m_CaseSens As Boolean<br />
Private m_Visible As Boolean<br />
Private m_AppTitle As String</p>
<p>Public Enum FindWindowPartialTypes<br />
&#160;&#160; FwpStartsWith = 0<br />
&#160;&#160; FwpContains = 1<br />
&#160;&#160; FwpMatches = 2<br />
End Enum</p>
<p>Public Function AppActivatePartial(AppTitle As String, Optional Method As FindWindowPartialTypes = FwpStartsWith, Optional CaseSensitive As Boolean = False) As Long<br />
&#160;&#160; Dim hWndApp As Long<br />
&#160;<br />
&#160;&#160; hWndApp = FindWindowPartial(AppTitle, Method, CaseSensitive, True)<br />
&#160;&#160; If hWndApp Then<br />
&#160;&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160;&#160; If IsIconic(hWndApp) Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Call ShowWindow(hWndApp, SW_RESTORE)<br />
&#160;&#160;&#160;&#160;&#160; End If<br />
&#160;&#160;&#160;&#160;&#160; Call SetForegroundWindow(hWndApp)<br />
&#160;&#160;&#160;&#160;&#160; AppActivatePartial = hWndApp<br />
&#160;&#160; End If<br />
End Function</p>
<p>Public Function FindWindowPartial(AppTitle As String, _<br />
&#160;&#160; Optional Method As FindWindowPartialTypes = FwpStartsWith, _<br />
&#160;&#160; Optional CaseSensitive As Boolean = False, _<br />
&#160;&#160; Optional MustBeVisible As Boolean = False) As Long<br />
&#160;&#160;<br />
&#160;&#160; m_hWnd = 0<br />
&#160;&#160; m_Method = Method<br />
&#160;&#160; m_CaseSens = CaseSensitive<br />
&#160;&#160; m_AppTitle = AppTitle<br />
&#160;<br />
&#160;&#160; If m_CaseSens = False Then<br />
&#160;&#160;&#160;&#160;&#160; m_AppTitle = UCase$(m_AppTitle)<br />
&#160;&#160; End If<br />
&#160;<br />
&#160;&#160; Call EnumWindows(AddressOf EnumWindowsProc, MustBeVisible)<br />
&#160;&#160; FindWindowPartial = m_hWnd<br />
End Function</p>
<p>Private Function EnumWindowsProc(ByVal hWnd As Long, ByVal lParam As Long) As Long<br />
&#160;&#160; Static WindowText As String<br />
&#160;&#160; Static nRet As Long</p>
<p>&#160;&#160; If lParam Then<br />
&#160;&#160;&#160;&#160;&#160; If IsWindowVisible(hWnd) = False Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; EnumWindowsProc = True<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Exit Function<br />
&#160;&#160;&#160;&#160;&#160; End If<br />
&#160;&#160; End If</p>
<p>&#160;&#160; WindowText = Space$(256)<br />
&#160;&#160; nRet = GetWindowText(hWnd, WindowText, Len(WindowText))<br />
&#160;&#160; If nRet Then<br />
&#160;&#160;&#160;<br />
&#160;&#160;&#160;&#160;&#160; WindowText = Left$(WindowText, nRet)<br />
&#160;&#160;&#160;&#160;&#160; If m_CaseSens = False Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; WindowText = UCase$(WindowText)<br />
&#160;&#160;&#160;&#160;&#160; End If<br />
&#160;&#160;<br />
&#160;&#160;&#160;&#160;&#160; Select Case m_Method<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Case FwpStartsWith<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; If InStr(WindowText, m_AppTitle) = 1 Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; m_hWnd = hWnd<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; End If<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Case FwpContains<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; If InStr(WindowText, m_AppTitle) &lt;&gt; 0 Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; m_hWnd = hWnd<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; End If<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Case FwpMatches<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; If WindowText = m_AppTitle Then<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; m_hWnd = hWnd<br />
&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; End If<br />
&#160;&#160;&#160;&#160;&#160; End Select<br />
&#160;&#160; End If<br />
&#160;<br />
&#160;&#160; EnumWindowsProc = (m_hWnd = 0)<br />
End Function</p>
<p>
</div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://programmervb.blog.com/2008/05/09/find-something/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
