Thursday, July 4, 2013

VB6 Internet - Membuat FTP Uploader

Seringkali kita membutuhkan aplikasi untuk mengupload file melalui ftp, nah, untuk keperluan ini kita bisa memperolehnya banyak, mulai dari gratis hingga berbayar dari yang kurang lengkap hingga yang memiliki fitur lengkap. Aplikasi tersebut memang dikhususkan untuk keperluan yang serius. Tetapi setelah mencoba beberapa darinya, rasanya tidak sebanding dengan fiturnya yang hebat dan loadingya yang berat jika hanya digunakan untuk mengupload file-file lampiran (file-file source code VB) yang ukurannya hnaya 3kb, 5kb atau belasan kb. Lalu bagaimana solusinya?

Di bawah ini merupakan source code FTP yang dibuat menggunakan VB6 beserta file Installernya (setup.exe) yang bisa digunakan untuk membantu pekerjaan blogging.
VB6 FTP uploader
Gambar - VB6 FTP uploader

Cara menggunakan:
  1. Terlebih dahulu kita harus memiliki hosting, baik berbayar maupun gratisan. Untuk yang gratisan bisa daftar di sini. Detail mengenai pendaftaran bisa dilihat disini
  2. Download source code ftp disini atau file setup.exe disini
  3. Selanjutnya dalam aplikasi tersebut, kita harus mengisi:
        • Host = alamat ftp
        • Username = username Anda
        • Password = password
        • Remote Dir. = remote directory public
        • Situs = domain yang sudah Anda buat
  4. Jika seluruhnya dirasa sudah benar, pilihlah salah satu file .zip yang ukurannya sekitar belasan kb.
  5. Pada Explorer context menu, klik Upload File with Khoiriyyah-FTP seperti yang terlihat pada gambar di bawah ini:
  6. FTP context menu
    Gambar - FTP Context Menu

  7. Tunggu beberapa saat hingga selesai proses upload.
  8. Setelah selesai, kita memperoleh link untuk dicopy-pastekan ke dalam artikel seperti terlihat pada gambar di bawah ini:
VB6 FTP uploader finish
Gambar - Proses upload selesai

Download: Source Code VB6 FTP uploader.
Download: Setup VB6 FTP uploader
.
READ MORE - VB6 Internet - Membuat FTP Uploader

Wednesday, July 3, 2013

DeRef Dalam VB6

Dengan memanfaatkan salah satu fungsi (GetMem4) yang berada dalam runtime VB6 (msvbvm60.dll).
Option Explicit 

Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)
Private Declare Sub GetDWord Lib "MSVBVM60.dll" Alias "GetMem4" (ByRef inSrc As Any, ByRef inDst As Long)

Public Function DeRef(ByVal ptr As Long) As Long
If (ptr) Then
Call GetDWord(ByVal ptr, DeRef)
End If
End Function

Private Sub Command1_Click()

Dim lngTest As Long
Dim lngAddress As Long

lngTest = 100
lngAddress = VarPtr(lngTest) 'lngAddress sekarang berisi pointer lngTest
Text1.Text = DeRef(lngAddress) 'Perhatikan sekarang Text1.Text = 100 (yang berasal dari pointer lngTest)

End Sub
READ MORE - DeRef Dalam VB6

Monday, July 1, 2013

VB6 Add-Ins - Mengambil String Terpilih (Code Module)

Mengenai cara mengambil string terpilih (selected) dari code module. Adapun kodenya adalah seperti di bawah ini:

Public Function GetSelections() As String 

Dim cd As CodePane
Dim cm As CodeModule

Set cd = VBInstance.ActiveCodePane
Set cm = VBInstance.ActiveCodePane.CodeModule

Dim StartLine As Long
Dim StartColoum As Long
Dim EndLine As Long
Dim EndColoum As Long

Dim sKeyword As String

cd.GetSelection StartLine, StartColoum, EndLine, EndColoum
sKeyword = cm.Lines(StartLine, EndLine)
GetSelections = Mid$(sKeyword, StartColoum, EndColoum - StartColoum)

End Function
READ MORE - VB6 Add-Ins - Mengambil String Terpilih (Code Module)

VB6 Add-Ins Tools - Win32 Keyword Search

Dikarenakan saya tidak memiliki MSDN jadinya harus report membuat tools yang seperti ini. Tools ini gunanya untuk melakukan pencarian pada:
  1. Win32.hlp (sebelumnya Anda harus memiliki file Win32.hlp ukurannya 24MB)
  2. API-Guide.exe
  3. Google (dengan keyword ... + VB6)

Hasilnya, pada menu klik kanan VB6 terdapat 3 tambahan menu seperti terlihat pada gambar:

Win32 Keyword Search
Win32 Keyword Search

Adapun potongan kodenya adalah seperti di bawah:
'----------------------------------------------------------------------------- 
' http://khoiriyyah.blogspot.com
'-----------------------------------------------------------------------------

Option Explicit

Const HELP_COMMAND = &H102&
Const HELP_CONTENTS = &H3&
Const HELP_CONTEXT = &H1
Const HELP_CONTEXTPOPUP = &H8&
Const HELP_FORCEFILE = &H9&
Const HELP_HELPONHELP = &H4
Const HELP_INDEX = &H3
Const HELP_KEY = &H101
Const HELP_MULTIKEY = &H201&
Const HELP_PARTIALKEY = &H105&
Const HELP_QUIT = &H2
Const HELP_SETCONTENTS = &H5&
Const HELP_SETINDEX = &H5
Const HELP_SETWINPOS = &H203&

Private Declare Function WinHelp Lib "user32.dll" Alias "WinHelpA" (ByVal hWndMain As Long, ByVal lpHelpFile As String, ByVal uCommand As Long, dwData As Any) As Long
Private Declare Function
ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal LpszDir As String, ByVal FsShowCmd As Long) As Long

Public VBInstance As VBIDE.VBE

Private oWin32Search As Office.CommandBarControl
Private oGoogleSearch As Office.CommandBarControl
Private oAPIGuideSearch As Office.CommandBarControl

Private WithEvents Win32Search As CommandBarEvents
Private WithEvents GoogleSearch As CommandBarEvents
Private WithEvents APIGuideSearch As CommandBarEvents

Private Sub SearchKeyword(Keyword As String)
Dim ret As Long
ret = WinHelp(frmDummy.hwnd, App.Path & "\win32.hlp", HELP_KEY, ByVal Keyword)
End Sub

Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)

On Error GoTo ErrHandler:

Set VBInstance = Application

If ConnectMode = ext_cm_Startup Then
Set oWin32Search = AddItemToMenu("&Win32 Keyword Search", "Code Window")
Set Win32Search = VBInstance.Events.CommandBarEvents(oWin32Search)

Set oGoogleSearch = AddItemToMenu("&Google Search", "Code Window")
Set GoogleSearch = VBInstance.Events.CommandBarEvents(oGoogleSearch)

Set oAPIGuideSearch = AddItemToMenu("&API-Guide Search", "Code Window")
Set APIGuideSearch = VBInstance.Events.CommandBarEvents(oAPIGuideSearch)
End If

Exit Sub

ErrHandler:

MsgBox Err.Description

End Sub

Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
On Error Resume Next
Call oWin32Search.Delete
Set oWin32Search = Nothing
Call oGoogleSearch.Delete
Set oWin32Search = Nothing
Call oWin32Search.Delete
Set oAPIGuideSearch = Nothing
Set Win32Search = Nothing
Set GoogleSearch = Nothing
Set APIGuideSearch = Nothing
Set VBInstance = Nothing
End Sub

Private Function AddItemToMenu(sCaption As String, sMenuName As String, Optional Bitmap As Object) As Office.CommandBarControl

Dim cbMenuCommandBar As Office.CommandBarControl
Dim cbMenu As CommandBar
Dim oTemp As Object
Dim sClipText As String

On Error GoTo ErrHandler:

Set cbMenu = VBInstance.CommandBars(sMenuName)
If cbMenu Is Nothing Then Exit Function

Set cbMenuCommandBar = cbMenu.Controls.Add(msoControlButton, , , VBInstance.CommandBars(sMenuName).Controls.Item("&Definition").Index)
cbMenuCommandBar.Caption = sCaption

' If Not Bitmap Is Nothing Then
' With Clipboard
' sClipText = .GetText
' Set oTemp = .GetData
' .SetData Bitmap, vbCFBitmap
' cbMenuCommandBar.PasteFace
' .Clear
' If Not oTemp Is Nothing Then
' .SetData oTemp
' End If
' .SetText sClipText
' End With
' If Err Then GoTo ErrHandler
' End If

Set AddItemToMenu = cbMenuCommandBar

Exit Function

ErrHandler:

MsgBox Err.Description

End Function

Private Sub Win32Search_Click(ByVal CommandBarControl As Object, handled As Boolean, CancelDefault As Boolean)
Dim sSelections As String
sSelections = GetSelections
If Trim$(sSelections) = "" Then Exit Sub
Call SearchKeyword(sSelections)
End Sub

Private Sub GoogleSearch_Click(ByVal CommandBarControl As Object, handled As Boolean, CancelDefault As Boolean)
Dim r As Long
Dim sSelections As String
sSelections = Trim$(GetSelections)
If sSelections = "" Then Exit Sub
r = ShellExecute(0, "open", "http://www.google.com/search?q=" & sSelections & "+VB6", 0, 0, 1)
End Sub

Private Sub APIGuideSearch_Click(ByVal CommandBarControl As Object, handled As Boolean, CancelDefault As Boolean)
Dim sSelections As String
sSelections = Trim$(GetSelections)
If sSelections = "" Then Exit Sub
Dim wsh As New IWshRuntimeLibrary.WshShell
wsh.RegWrite "HKCU\Software\KPD-Team\API-Guide\LastAPI", sSelections
Shell "C:\Program Files\API-Guide\API-Guide.exe", vbNormalFocus
End Sub

Public Function GetSelections() As String

Dim cd As CodePane
Dim cm As CodeModule

Set cd = VBInstance.ActiveCodePane
Set cm = VBInstance.ActiveCodePane.CodeModule

Dim StartLine As Long
Dim StartColoum As Long
Dim EndLine As Long
Dim EndColoum As Long

Dim sKeyword As String

cd.GetSelection StartLine, StartColoum, EndLine, EndColoum
sKeyword = cm.Lines(StartLine, EndLine)
GetSelections = Mid$(sKeyword, StartColoum, EndColoum - StartColoum)

End Function
Selengkapnya bisa didownload pada link di bawah ini:
Download: Win32KeywordSearch
READ MORE - VB6 Add-Ins Tools - Win32 Keyword Search