|
|
|
|
|
|
|
|
DragControl - Drag any control using the mouse
|
Total Hit (3088) |
«Code LangId=1»
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function ClipCursor Lib "user32" (lpRect As RECT) As Long
Private Declare Function Cli
....Read More |
Rating
|
|
|
|
ReplaceMulti - Multiple string replacements
|
Total Hit (1907) |
«Code LangId=1»' Perform multiple substitutions in a string
' The first argument is the string to be searched
' The second argument is vbBinaryCompare or vbTextCompare
' and tells whether the search is case sensitive or not
' The following arguments are pairs of (find, replace) strings
'
....Read More |
Rating
|
|
|
GetPrimeNumbers - Evaluate the first N prime numbers
|
Total Hit (1638) |
«Code LangId=1»' Returns an array with the first N prime numbers
'
' Note: you can easily convert this routine to VB4 and VB5 by
' returning the result array through an argument instead of
' the return value
Function GetPrimeNumbers(numberOfPrimes As Long) As Long()
Dim found As Long
....Read More |
Rating
|
|
|
Open MS-DOS prompt from any directory in Explorer
|
Total Hit (2704) |
By adding a couple Registry keys you can add a commond to the context menu that appear when you right-click a directory when inside Windows Explorer. The new command lets you open the MS-DOS prompt and navigate to that directory with just one mouse click:
«Code LangId=1»
---------------------
....Read More |
Rating
|
|
|
Get the list of ODBC drivers
|
Total Hit (4294) |
The ODBCTOOL.DLL library contains three functions that make it easier to manage DSNs. To run the following code you must add a reference to the "ODBC Driver & Data Source Name Functions" library to your References dialog box. If you don't find this library listed in the References list, use the Star
....Read More |
Rating
|
|
|
Insert a picture into a RichTextBox control
|
Total Hit (4053) |
Here's a simple method to programmatically insert an image into a RichTextBox control, by copying it into the clipboard and then pasting it into the control:
«Code LangId=1»
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal _
hwnd As Long, ByVal wMsg As Long, By
....Read More |
Rating
|
|
|
Remove the Close command from the system menu
|
Total Hit (3245) |
If you want to prevent the user from closing a form by using Alt+F4 or by clicking on the "X" button in the upper-right corner you just need to write some code in the form's QueryUnload event procedure:
«Code LangId=1»
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
....Read More |
Rating
|
|
|
Ensure that a TextBox caret is visible
|
Total Hit (3153) |
Setting a multiline TextBox's SelStart property doesn't ensure that the insertion point (the caret) is visible. You can achieve this by sending the control an appropriate message:
|
Rating
|
|
|
Count Sort, a special case of indexed sort
|
Total Hit (2939) |
CountSort is yet another sort algorithm, which can be applied only under very particular conditions but that, when such conditions are met, turns to be the fastest of the lot. Count Sort can be used when the key is of Integer type, or when it is of Long type but the range of values is not too large.
....Read More |
Rating
|
|
|
Show ChooseFont dialogbox using API
|
Total Hit (5571) |
You can use ChooseFont API to show Font selection common dialogbox. This API will eliminate the need of Common Dialog ActiveX control which comes with Visual Basic.
«b»Step-By-Step Example«/b»
- Create a standard exe project
- Add one commandbutton on the form1
- Add the following code in fo
....Read More |
Rating
|
|
|
|
Tip: How to display all environment variables
|
Total Hit (2514) |
«code LangId=1»Private Declare Function GetEnvironmentStrings Lib "kernel32" Alias "GetEnvironmentStringsA" () As Long
Private Declare Function FreeEnvironmentStrings Lib "kernel32" Alias "FreeEnvironmentStringsA" (ByVal lpsz As String) As Long
Private Declare Function lstrlen Lib "kernel32" Alias
....Read More |
Rating
|
|
|
Extending the functionality of the VB ListView controls
|
Total Hit (2175) |
The "ListView" control in both Comctl32.ocx and Mscomctl.ocx is simply a wrapper that superclasses (encapsulates) the real "listview" common control in Comctl32.dll. This allows the real listview common control messages and definitions to be used to override almost every aspect of the VB ListView co
....Read More |
Rating
|
|
|
Simulating a TopIndex Property for a ListView
|
Total Hit (751) |
A listview control's EnsureVisible method provides a means to bring a referenced item into view. Ditto, the LVM_ENSUREVISIBLE message simply "ensures that a list-view item is either entirely or partially visible, scrolling the list-view control if necessary."
If the item of interest is back up t
....Read More |
Rating
|
|
|
Autosizing ListView Columns via API
|
Total Hit (1826) |
The ListView control in both VB5 and VB6 implementations supports SendMessage with the LVSCW_AUTOSIZE and LVSCW_AUTOSIZE_USEHEADER messages to cause the ListView to adjust its column widths to maximize data display. This page shows how to use these messages to resize the columns to fit the longest c
....Read More |
Rating
|
|
|
Filling a Combo with Files, Directories and Drives
|
Total Hit (1169) |
This routine demonstrates using SendMessage to populate a combo box with any combination of files, directories and drives. Although this demo uses the wildcard *.*, the method is valid for any mask.
|
Rating
|
|
|
Start a document based on its filename
|
Total Hit (1267) |
Starting any document file based on its file name only is very simple in Windows using the ShellExecute function. This tip shows how simple it is - you only really need one declare and one line of code!
|
Rating
|
|
|
Show and Hide a Form's Titlebar at run-time
|
Total Hit (2362) |
This tip shows you how to show and hide the title bar of a window at run-time. To make a window's title bar disappear, you have to remove the control box, the maximise box and the minimise box as well as set the caption of the form to blank. Unfortunately, VB's ControlBox, MinButton and MaxButton pr
....Read More |
Rating
|
|
|
Dealing with Circular References
|
Total Hit (1690) |
VB and COM makes a lot of things easy to do, particularly using and dealing with objects: you just create them and normally they clear themselves up automatically once you're finished with them. However, one side effect of the way COM works is that it is possible to create objects which cannot termi
....Read More |
Rating
|
|
|
Drawing Buttons, Option Boxes and Check Boxes In Your Own Style
|
Total Hit (2267) |
If you set the Style property for VB's CommandButton, OptionBox or CheckBox controls to Graphical, VB turns the control into an Owner-Draw control. By default VB allows you to associate three pictures with these controls. However, if you've ever tried this you will know that the button draws like a
....Read More |
Rating
|
|
|
Flicker Free API Drawing
|
Total Hit (2940) |
VB offers a way to reduce flicker when drawing a control through its AutoRedraw property. When AutoRedraw is set, VB creates an Off-Screen buffer to draw into, and only transfers this to the drawing surface when the Refresh method is called. Whilst this works well (ish), it doesn't help if you need
....Read More |
Rating
|
|
|
Implementing a Distributed Algorithm in Visual Basic
|
Total Hit (2245) |
An illustrative algorithm is implemented in Visual Basic, emphasizing all the four fundamental aspects of distributed computing systems: resource sharing, computation speedup, reliability, and communication. Winsock control is used to provide effective communication and resource sharing between the
....Read More |
Rating
|
|