Get File MD5 Hash Using VB6

To get a file’s MD5 Hash using Visual Basic 6, download and add the following clsMD5 class to your VB project.

Download: clsMD5.zip

 

Add a command button (Command1), a text box (Text1) and use the following code:

Private Function GetFileMD5(ByVal FileName As String) As String
    Dim MD5 As New clsMD5, FF As Integer, Buff() As Byte
    Const BuffSize As Long = 2 ^ 16 ' (64 KBytes)

'    On Error GoTo ErrExit
    FF = FreeFile
    Open FileName For Binary Access Read As FF
        MD5.MD5Init

        Do Until Loc(FF) >= LOF(FF)
            If Loc(FF) + BuffSize > LOF(FF) Then
                ReDim Buff(LOF(FF) - Loc(FF) - 1)
            Else
                ReDim Buff(BuffSize - 1)
            End If

            Get FF, , Buff
            MD5.MD5Update UBound(Buff) + 1, Buff
        Loop

        MD5.MD5Final
        GetFileMD5 = MD5.GetValues
    Close FF

    Exit Function
ErrExit:
    Err.Clear
    GetFileMD5 = ""
End Function

Private Sub Command1_Click()
Text1.Text = GetFileMD5("c:\example.exe")
End Sub

Extract Links or URLs from A Web Page – Visual Basic 6 (VB6)

Extracting Links Using VB6

This is an easy way to extract links from a web page using a web browser control and a reference to Microsoft HTML Object Library. This code will extract all links in the href property of the A tag and save them to a text file named urllist.

  • Create a form.
  • Add reference to Microsoft Html Object Library.
  • Add a web browser control.
  • Add a List Box
  • Add a command button.

VB Code:

 

Private Sub Command1_Click()
    Dim c
    Dim aLink As Object

    For Each aLink In WebBrowser1.Document.All.tags("A")
        List1.AddItem aLink.href
    Next aLink

    Open App.Path & "\urllist.txt" For Output As #1
        For c = 0 To List1.ListCount - 1
            Print #1, List1.List(c)
        Next
    Close #1
End Sub

Private Sub Form_Load()
    WebBrowser1.Navigate "http://www.fatherofcents.com/"
End Sub

Download: Extracting Links in Visual Basic Extract-Links-VB6.zip