|
|
|
|
|
|
|
|
LOG Files
|
Total Hit (2682) |
«Code LangId=1»'Just place this in a Module and you can call it from anywhere in your program!
Sub SetLog(Message As String)
'This Sub writes to a LOG file.
Dim theFile As String, theMessage As String
theFile = App.Path & "\PRGMLOG.TXT"
theMessage = Message & vbCrLf
Open theFile For Append A
....Read More |
Rating
|
|
|
NodeNestingLevel - The nesting level of a TreeView's node
|
Total Hit (2292) |
«Code LangId=1»' Returns the nesting level of a TreeView's Node object
' (returns zero for root nodes.)
Function NodeNestingLevel(ByVal Node As Node) As Integer
Do Until (Node.Parent Is Nothing)
NodeNestingLevel = NodeNestingLevel + 1
Set Node = Node.Parent
Loop
End
....Read More |
Rating
|
|
|
|
|
RotateRight - Rotate a Long to the right
|
Total Hit (1792) |
«Code LangId=1»' Rotate a Long to the right the specified number of times
'
' NOTE: requires Power2()
Function RotateRight(ByVal value As Long, ByVal times As Long) As Long
Dim i As Long, signBits As Long
' no need to rotate more times than required
times = times Mod 32
....Read More |
Rating
|
|
|
Create a GUID
|
Total Hit (3860) |
When you build your ActiveX controls and components, Visual Basic automatically creates all the GUIDs as necessary. The same also happens in other cases, without you even realizing it: for instance when you make a MDB database replicable, the Jet Engine adds new fields and uses GUIDs to mark their c
....Read More |
Rating
|
|
|
Default Properties tend to hide programming mistakes
|
Total Hit (2763) |
Visual Basic lets you create a default property or method by simply selecting the "(Default)" item in the combo box that appear if you click the Advanced button in the Procedure Attributes dialog box. (You can display this dialog from the Tools menu, or by right-clicking on a property name in the ri
....Read More |
Rating
|
|
|
Add multiple child controls to a Coolbar
|
Total Hit (2206) |
The Coolbar control consists of a collection of Band objects, and each Band object exposes a Child property. To move a control inside the Coolbar you just have to assign it to the Child property of a Band object.
A minor problem is that you can't directly assign multiple controls to one Band. The
....Read More |
Rating
|
|
|
Open the list portion of a ComboBox control
|
Total Hit (2981) |
To programmatically open and close the list portion of a ComboBox control, all you need is sending the CB_SHOWDROPDOWN message to the control. Here is a routine that encapsulate the SendMessage API function:
«Code LangId=1»
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
....Read More |
Rating
|
|
|
Add size grips to a form
|
Total Hit (2777) |
There are two simple ways to add the so-called size-grips to the bottom-right corner of a form. The first method is to add a StatusBar control, which includes a size-grip of its own. The second method is to add a multiline TextBox control, set its ScrollBars property to 3-Both and add some resizing
....Read More |
Rating
|
|
|
Change a CheckBox or OptionButton style at runtime
|
Total Hit (4215) |
Visual Basic doesn't let you change the Style property of a CheckBox or an OptionButton control at runtime. However, you can easily do it by manipulating the control's style bit, with the SetWindowLong API function. Here's a routine that does the trick:
Using the routine is straightforward. For
....Read More |
Rating
|
|
|
Non obvious uses for the LIKE operator
|
Total Hit (2992) |
LIKE is probably the VB operator is most underutilized if compared to its potential. The most immediate use for this operator is to check that a string begins or ends with a given pattern. For example, it is simple to check that a Product ID is made up by a alphabetic character followed by three dig
....Read More |
Rating
|
|
|
Persistent breakpoints
|
Total Hit (3278) |
When you close a VB IDE session, VB saves the code but doesn't save the current set of breakpoints. If you need (non-conditional) breakpoints to persist among sessions, don't use the F9 key. Instead, use the following statement
«Code LangId=1»
Debug.Assert False
«/Code»
The above code will alwa
....Read More |
Rating
|
|
|
|
|
How to Print Full Justified Text
|
Total Hit (3033) |
Module
«Code LangId=1» Option Explicit
Public Sub PrintLine(Text As String, SpaceWidth As Single, Target As Object)
'Print a justified line to the Target object
Dim i As Integer
Dim cx As Single
Dim OldBold As Boolean
Dim OldUnderLine As Boolean
Dim OldItalic As
....Read More |
Rating
|
|
|
|
|
Using DeviceIoControl to Obtain Physical Drive Information
|
Total Hit (1771) |
Win NT/Win2000 developers have access to a unique API that provides low-level system information - DeviceIoControl.
This example succeeds only when it runs on Windows NT/Windows 2000/Windows XP, for two reasons:
«LI»The standard device input/output control codes are available only on Windows N
....Read More |
Rating
|
|
|
Creating and using your own VC++ dlls
|
Total Hit (954) |
Using the Windows API is a wonderful way to speed up your applications when they need to perform processor intensive tasks like graphics manipulation. However, the Windows API doesn’t always provide all the functionality you need for your application. Perhaps some 3rd party control does what you wan
....Read More |
Rating
|
|
|
|
IconMenu Control
|
Total Hit (1594) |
The IconMenu (cPopMenu.ocx) control is a really simple way to get icons into a VB project's menus. It also allows you to create arbitrary new submenus, gives you control over the system menu and has some useful new events indicating when menu items are highlighted and exited.
....Read More |
Rating
|
|
|
Owner-Draw Pop-up Menus
|
Total Hit (1726) |
This project provides sample code for creating completely owner-drawn pop-up menu items using the PopupMenu ActiveX DLL. If you want to create a drop-down list of items from your control, and the number of items will fit onto the screen, then using this DLL to manage all the drop-down functions exce
....Read More |
Rating
|
|