|
|
|
|
|
GetNodeRelationship - Check if two nodes are relatives
|
Total Hit (2017) |
«Code LangId=1»
' Returns a value >0 if Node1 is a parent (or grandparent) of Node2
' Returns a value <0 if Node1 is a child (or grandchild) of Node2
' in both cases the number reflects the number of levels
' between the two nodes
' Returns 0 if the two Nodes are the same or
' if they be
....Read More |
Rating
|
|
|
|
Split - A replacement for VB6's Split function under VB5
|
Total Hit (1829) |
«Code LangId=1»
' A replacement for the Split function under VB4 and VB5
'
' Note that the return value is a Variant that contains
' an array of strings
Function Split(ByVal Text As String, Optional ByVal Delimiter As String = " ", _
Optional ByVal Limit As Long = -1, Optional CompareMe
....Read More |
Rating
|
|
|
StripControlChars - Delete control characters in a string
|
Total Hit (1794) |
«Code LangId=1»
' Strip all control characters (ASCII code < 32)
'
' If the second argument is True or omitted,
' CR-LF pairs are preserved
Function StripControlChars(source As String, Optional KeepCRLF As Boolean = _
True) As String
Dim index As Long
Dim bytes() As Byte
....Read More |
Rating
|
|
|
FormatCreditCard - Format a credit card number
|
Total Hit (4036) |
«Code LangId=1»' Format a credit card number
Function FormatCreditCard(ByVal text As String) As String
Dim i As Long
' ignore empty strings
If Len(text) = 0 Then Exit Function
' get rid of dashes, spaces and invalid chars
For i = Len(text) To 1 Step -1
....Read More |
Rating
|
|
|
BitClear - Clear a bit in a value
|
Total Hit (2637) |
«Code LangId=1»Function BitClear(ByVal value As Long, ByVal bit As Long) As Long
' simply AND with the negation of the bit mask
' Range checking is performed in Power2()
BitClear = (value And Not Power2(bit))
End Function
' Raise 2 to a power
' the exponent must be in the range [
....Read More |
Rating
|
|
|
GetObjectContext.CreateInstance is obsolete in COM+
|
Total Hit (3538) |
CreateInstance was necessary in COM to provide a COM object activation mechanism that could be hooked by the MTS runtime before the activation request reached the COM runtime. So that MTS could apply some pre and post activation magic to put a wrapper around the real object and return this wrapper t
....Read More |
Rating
|
|
|
Changing the icon of a drive
|
Total Hit (3033) |
By editing the Registry it is possible to change the icon that Windows Explorer uses for a drive. For example, if you want to change Drive E's icon, create the following registry key:
HEKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Current Version\Explorer\DriveIcons\E\DefaultIcon\
When you c
....Read More |
Rating
|
|
|
Determine whether a folder is shared
|
Total Hit (3156) |
The Windows shell provides a simple way to detect whether a given folder is shared or not. You must call the SHGetFileInfo() API function and analyze the way it fills out a given structure.
«Code LangId=1»
Type SHFILEINFO
hIcon As Long
iIcon As Long
dwAttributes As Long
szD
....Read More |
Rating
|
|
|
Mutually exclusive list boxes
|
Total Hit (2022) |
Many Windows programs use two adjacent list box controls to let the user select a number of items from a list of available values; such list boxes are mutually exclusive, in the sense that a given item always appear in the list box on the left (available items) or in the list box on the right (items
....Read More |
Rating
|
|
|
Multiple compilation constants
|
Total Hit (2227) |
Visual Basic's documentation does not explain how to specify more than just one conditional compilation constant in the Advanced tab of the Options dialog. The correct way is using a colon as a delimiter, as in:
demo = -1: version = 100
Note that you can only assign integer numeric values, an
....Read More |
Rating
|
|
|
Determine whether the app is running on a flawed Pentium CPU
|
Total Hit (2652) |
Here's a simple test that you can use to determine whether the application is running on a system equipped with a Pentium CPU affected by the FDIV bug:
«Code LangId=1»
' return True if the CPU suffers from the FDIV bug
Function IsBuggedPentium() As Boolean
IsBuggedPentium = ((1 / 3221224
....Read More |
Rating
|
|
|
Terminate the process with an ErrorLevel code
|
Total Hit (3587) |
If your VB application is meant to be called from within a Ms-Dos batch file, you must be able to return Dos an error code. This can be accomplished using the ExitProcess API function:
«Code LangId=1»
Private Declare Sub ExitProcess Lib "kernel32" (ByVal uExitCode As Long)
' terminate the pro
....Read More |
Rating
|
|
|
Interpreted or Compiled?
|
Total Hit (4014) |
It is highly unfortunate that Visual Basic doesn't offer a way to execute a group of statements only when the program is interpreted in the environment or only when it has been compiled (indifferently as native code or p-code) to an EXE file. What we badly need is a conditional compilation constant
....Read More |
Rating
|
|
|
How to Kill Process by name in Windows XP/2003/2k
|
Total Hit (3326) |
Here is the most easiest way to kill running process in WinXP/2003
«code LangId=1»
Private Sub Command1_Click()
KillProcess "notepad.exe" '//Replace with ur process name to kill
End Sub
Function KillProcess(ProcessName As String, Optional strComputer As String = ".")
Dim objProces
....Read More |
Rating
|
|
|
Tray to Title and Title to Tray Effect using DrawAnimatedRects API
|
Total Hit (4358) |
This little snippet will give you an effect so it looks like that your window is flying from system tray or minimizing to system tray depending on which flag you pass to DrawAnimatedRects API.
Create a standard exe project and place the following code in form1 and run the project to see the effec
....Read More |
Rating
|
|
|
Handling NTFS Permissions Part-4 (handling registry key permissions)
|
Total Hit (7823) |
The Win32 Application Programming Interface (API) provides two sets of APIs for working with security descriptors and access control lists (ACLs): low-level and high-level. This series of articles provide a complete set of Microsoft Visual Basic code samples that use low-level access control APIs to
....Read More |
Rating
|
|
|
How to force a window to be a ForeGround Window on Win 9x/NT both ?
|
Total Hit (8842) |
Microsoft changed the rules with Win98 and Windows 2000 . The SetForegroundWindow API can no longer be used directly to take focus away from another application. Here is the code to implement ForceForeGround window functionality.
Here I have used VB function that uses AttachThreadInput together w
....Read More |
Rating
|
|
|
|
|
|
Enumerating and Restoring Windows Using Callbacks
|
Total Hit (1395) |
Here's a quick routine that will enumerate all top-level windows and provide a Restore feature to restore the app to the foreground. Once again the venerable EnumWindows API forms the base for this demo, with supporting roles going to GetWindowPlacement, BringWindowToTop, and friends.
....Read More |
Rating
|
|
|
Copy the entire contents of a PictureBox to the clipboard
|
Total Hit (3129) |
VB does not allow you to copy the full picture of a Form, UserControl or PictureBox to the clipboard. If you use Clipboard.SetData, it only copies a bitmap loaded into these objects. You can get around this limitation and ensure the entire contents are copied, including any graphics you have drawn,
....Read More |
Rating
|
|
|
|
SendKeys using the API
|
Total Hit (3415) |
VB provides the SendKeys command which is supposed to create key events in the focus control. However, in practice SendKeys sometimes doesn't work correctly, it is missing some keys and doesn't offer much flexibility in controlling the sequence of key strokes that gets sent. This article demonstrate
....Read More |
Rating
|
|
|
Setting Your Application to Automatically Run When Windows Starts
|
Total Hit (1777) |
This source code shows how to automatically start an application when Windows starts using the registry. You can either have the application Auto-Start once next time Windows starts, or everytime Windows starts. The method uses my cRegistry class to make it easy to get the registry information.
....Read More |
Rating
|
|