Posts

Showing posts from May, 2013

How to enable Mouse Wheel Scrolling in VB6

Image
This article will guide you through on how to enable Mouse Wheel Scrolling in VB6 . 1. You need to download the Microsoft's VB6 Mouse Wheel Addin . 2. Run the Self-Cabinet Extractor and Unzip the necessary files.    You may change the destination to accessible location "C:\vb6mwfix". 3. Open " Run ", copy and paste this code " xcopy C:\vb6mwfix\VB6IDEMouseWheelAddin.dll %windir%\system32\VB6IDEMouseWheelAddin.dll " without " qoutes ". 4. Press " F " to confirm the destination as file. 5. Open " Run ", copy and paste this code " regsvr32 %windir%\system32\VB6IDEMouseWheelAddin.dll " without " qoutes " to register the add-in. 6. Open the "VBA Mouse Wheel Fix.reg " located on the folder where you extract the files to add the addin information in the registry. 7. Start your Microsoft Visual Basic 6.0 . 8. Open Add-Ins Manager.    9. Select " MouseWheelFix " in the av

Make an application on top of another window in VB6

Maintaining an application on top of other applications, regardless if they were present on the screen or are called later is. VB6: Maintaining an application over the others     * In a general module     * In the opening form     * Calling the function     * Removing priority Copy and paste this in a General Module. Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal_     hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As _     Long, ByVal cy As Long, ByVal wFlags As Long) As Long Public Const HWND_TOPMOST = -1 Public Const HWND_NOTOPMOST = -2 Public Const SWP_NOACTIVATE = &H10 Public Const SWP_SHOWWINDOW = &H40 Public Const SWP_NOMOVE = 2 Public Const SWP_NOSIZE = 1 Put this in your form. Private Sub Form_Load()     Dim R as long     R = SetWindowPos(SheetName.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE) End sub Calling the function The function must be put in the activation of the form

Compact a JET database using ADO in VB6

The following routines demonstrates how to compact a JET database using ADO: Option Explicit 'Purpose : Compact a JET (Access) database using ADO 'Inputs : sDatabasePath The path to the database path eg. C:\nwind.mdb ' [bEncryptDatabase] If True, encrypts the contents of the database 'Outputs : Returns zero if successful, else returns error code 'Notes : Requires "Microsoft Jet and Replication Objects X.X library", ' where (X.X is greater than or equal to 2.1) ' Compacts the database by creating a temporary database with the extension .tmp then, ' if the compaction is successful, it overwrites the original database. ' Will not work if anyone else is connected to the database. 'Revisions : 'Assumptions : Function DatabaseCompact(sDatabasePath As String, Optional bEncryptDatabase As Boolean = False) As Long

Open an External File, URL, Email and System Apps in VB6

The ShellExecute function allows you to open external application, specific URL location, email address or launch system applications upon clicking on a single button. 1. Start a new Standard Exe Project. 2. Add this code in General Declarations . Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, & _ ByVal lpOperation As String, & _ ByVal lpFile As String, & _ ByVal lpParameters As String, & _ ByVal lpDirectory As String, & _ ByVal nShowCmd As Long) As Long 3. Add a command button on your form, change its name to cmdOpen. 4. DoubleClick on the form and try any of the codes below. '# Open file (quotes are used so that the actual value that is passed is "C:\test.txt" Private Sub cmdOpen_Click()     ShellExecute 0, vbNullString, """"C:\test.txt"""", vbNullString, vbNullString, vbNormalFocus End Su

Auto-adjust Column Width of a Listview Control in VB6

The following function auto adjusts column width of listview controls in vb6. Just copy and paste the code below on your project and call the function after loading data on your listview control. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Sub AutosizeColumns(ByVal TargetListView As ListView) Const SET_COLUMN_WIDTH As Long = 4126 Const AUTOSIZE_USEHEADER As Long = -2 Dim lngColumn As Long For lngColumn = 0 To (TargetListView.ColumnHeaders.Count - 1) Call SendMessage(TargetListView.hwnd, SET_COLUMN_WIDTH, lngColumn, ByVal AUTOSIZE_USEHEADER) Next lngColumn End Sub

VB KeyAscii Code and Values

Visual Basic KeyAscii Values can range from 0 to 255.  Here is a chart which shows all possible KeyAscii values along with the character which they represent.To type out any of these characters without pressing the actual character you can do this.Hold down the left ALT key on your keyboard and using the number pad on the right of your keyboard type in the corresponding ASCII value.For instance, typing ALT+66 will yield B . For numbers above 127 use "0 + the number". For instance to find the character which corresponds to KeyAscii value 134 you would type ALT+0134 which yields † . Note: KeyAscii values 0 to 31 are non-printable and values 128-255 are considered "Extended". These "extended" codes may vary in appearance from computer to computer, font to font and may not be displayed, so please use with caution. ASCII CHAR ASCII CHAR 0 NUL (null) / Ctrl+Shift+@ 128 € 1 SOH (start of heading) / ☺ / Ctrl+A 129 