How to Download a file from the Internet — without getting a dialog box (in two ways)
Posted on August 24, 2011
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 'Internet - How to Download a file from the Internet -- without getting a dialog box (in two ways) 'Method 1: Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" _ (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, _ ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long Private Sub Form_Load() Dim llRetVal As Long llRetVal = URLDownloadToFile(0, "http://www.yahoo.com", "c:\Temp.htm", 0, 0) End Sub 'Method 2: Private Declare Function DoFileDownload Lib "shdocvw.dll" (ByVal lpszFile As String) As Long Public Sub DownloadFile(FileURL As String) Dim sDownload As String sDownload = StrConv(FileURL, vbUnicode) Call DoFileDownload(sDownload) End Sub |
How to Display keyboard key pressed — including system keys
Posted on August 24, 2011
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 'Controls - How to Display keyboard key pressed -- including system keys Public Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Long, _ ByVal wMapType As Long) As Long Public Declare Function GetKeyNameText Lib "user32" Alias "GetKeyNameTextA" (ByVal lParam As Long, _ ByVal lbBuffer As String, ByVal nSize As Long) As Long Private Sub txtBody_KeyDown(KeyCode As Integer, Shift As Integer) Dim dummy& Dim scancode& Dim keyname As String * 256 'Get the scancode scancode& = MapVirtualKey(KeyCode, 0) dummy = GetKeyNameText(scancode& * &H10000, keyname, 255) MsgBox keyname KeyCode = 0 End Sub |
How to show Run Dialog
Posted on August 23, 2011
1 2 3 4 5 6 7 8 9 10 11 12 | 'System & API - How to show Run Dialog Private Declare Function SHRunDialog Lib "shell32" Alias "#61" (ByVal hwnd As Long, _ ByVal I_dont_know_1 As Long, ByVal I_dont_know_2 As Long, ByVal dTitle As String, _ ByVal dPrompt As String, ByVal uFlags As Long) As Long Private Sub Form_Load() 'No Browse Button. Need to enter the program path manually 'SHRunDialog hwnd, 0, 0, "This is Run dialog", "Please enter the program you wish to run ", 1 'Normal Run Dialog SHRunDialog hwnd, 0, 0, "This is Run dialog", "Please enter the program you wish to run ", 2 Unload Me End Sub |