|
|
|
|
|
|
|
GetTempFile - Create a temporary file
|
Total Hit (2827) |
«Code LangId=1»
Private Declare Function GetTempFileName Lib "Kernel32" Alias _
"GetTempFileNameA" (ByVal lpszPath As String, _
ByVal lpPrefixString As String, ByVal wUnique As Long, _
ByVal lpTempFileName As String) As Long
Private Declare Function GetTempPath Lib "Kernel32" Alias
....Read More |
Rating
|
|
|
CombSort - A very efficient algorithm
|
Total Hit (2302) |
«Code LangId=1»' Comb Sort an array of any type
'
' CombSort is faster than all but QuickSort and close to it.
' On the other hand, the code is much simpler than QuickSort
' and can be easily customized for any array type
' This routine is based on an article appeared on the Byte
' magazine i
....Read More |
Rating
|
|
|
ProjectName - The name of the current project
|
Total Hit (1895) |
«Code LangId=1»' Returns the name of the current project
' The first time it's called it clears the error code
'
Function ProjectName() As String
Static result As String
If Len(result) = 0 Then
On Error Resume Next
' cause a dummy, harmless error
Err.Raise 9
....Read More |
Rating
|
|
|
Don't let binary compatibility beat you
|
Total Hit (2832) |
When you decide to release a new version of an MTS/COM+ component you should take care of its compatibility with the previous version. There are three types of changes you could make:
(1) You change only internal code of a component, keeping the interface that the component provides untouched.
(
....Read More |
Rating
|
|
|
A simple way to control a common dialog's position
|
Total Hit (4206) |
The CommonDialog control doesn't provide any direct way to decide where a common dialog appears on the screen. In all cases, in fact, the control tries to display the common dialog centered on its owner form. This behavior suggests a simple way to affect the approximate position of the common dialog
....Read More |
Rating
|
|
|
|
Using Enter to move to next field
|
Total Hit (1660) |
Most MsDos programs used the Enter key to move from one field to the next one. You can easily simulate this behavior by setting the form's KeyPreview property to True and writing this code in the Form_KeyPress event:
«Code LangId=1»
Sub Form_KeyPress (KeyAscii As Integer)
If KeyAscii = 13 Th
....Read More |
Rating
|
|
|
Clone a Font object
|
Total Hit (2907) |
When you want to assign a control's Font to another control, the first obvious way is to assign the Font property directly, as in:
«Code LangId=1»
Set Text2.Font = Text1.Font
«/Code»
but in most cases this approach doesn't really work, because it assigns a reference to the same font to both c
....Read More |
Rating
|
|
|
The beginning or end of previous week
|
Total Hit (3813) |
For reporting, many times you need to figure out what date last week began and ended. Use the code below to figure that out:
|
Rating
|
|
|
Undocumented behavior of the CInt() function
|
Total Hit (3107) |
The CInt() function rounds to the nearest integer value. In other words, CInt(2.4) returns 2, and CInt(2.6) returns 3.
This function exhibits an under-documented behavior when the fractional part is equal to 0.5. In this case, this function rounds down if the integer portion of the argument is e
....Read More |
Rating
|
|
|
Two handy functions for Null handling
|
Total Hit (3182) |
You're probably aware that most VB functions don't work well with Null values, which is an issue when you're working with database columns that can accept Nulls. For example, the following statement:
«Code LangId=1»
Dim s as String
s = rs.Fields("AnyField")
«/Code»
can raise error 94 "Invali
....Read More |
Rating
|
|
|
Event logging doesn't work in interpreted applications
|
Total Hit (3512) |
The StartLogging and LogEvent methods of the App object only work in compiled applications. This behavior is by design and shouldn't be considered a bug, even though it isn't documented in the language manuals.
To work around this problem, just create an ActiveX DLL component that exposes the St
....Read More |
Rating
|
|
|
Count the number of files in a given directory
|
Total Hit (3314) |
API Declarations
«Code LangId=1» Option Explicit
'API constants
Public Const MAX_PATH = 260
Public Const INVALID_HANDLE_VALUE = -1
Public Const FILE_ATTRIBUTE_DIRECTORY = &H10
'API types
Public Type FILETIME
dwLowDateTime As Long
dwHighDateTime As Long
End Type
Public Typ
....Read More |
Rating
|
|
|
How To Read/Write Data File Using ReadFile and WriteFile API
|
Total Hit (7998) |
The Win32 API allows binary files to be opened and written using the CreateFile, ReadFile, and WriteFile APIs. These functions offer increased flexibility to write and read from files. This article demonstrates a technique to write large amounts of data, in the form of a large array, to a binary fil
....Read More |
Rating
|
|
|
|
|
|
Tutorial : Connecting to the remote FTP host
|
Total Hit (3258) |
In this tutorial we are going to find out the essential things that we need to know in order to use the library. We’ll examine the procedure of establishing FTP session with an FTP server. Such a procedure includes three operations: the TCP connection establishment to the FTP remote host, the user a
....Read More |
Rating
|
|
|
How to Share a Folder using NetShareAdd
|
Total Hit (1547) |
The NetShareAdd function shares a server or workstation resource. Only members of the Administrators or Account Operators local group, or those with Communication, Print, or Server operator group membership can successfully execute the NetShareAdd function. The Print operator can add only Printer qu
....Read More |
Rating
|
|
|
Using the GetOpenFileName Common Dialog API
|
Total Hit (1326) |
This page provides the detailed code and descriptions required for the Common Dialog GetOpenFileName API, as well as showing how to retrieve the constituent parts of the file string returned.
Code comments are at a minimum here. For detailed descriptions of the OPENFILENAME structure used and the
....Read More |
Rating
|
|
|
vbAccelerator Status Bar Control
|
Total Hit (1729) |
This article provides a full implementation of the ComCtl32 status bar control in VB, providing access to all of the features including Owner-Drawn panels.
|
Rating
|
|
|
vbAccelerator ImageList Control and Class v2.0
|
Total Hit (1668) |
As a number of my controls require image list support (Rebar and Toolbar control, Tab Control, S-Grid, Icon Menu Control, ActiveX Popup Menu DLL, Owner Drawn ComboEx Control and the Owner Drawn Combo and List box Control), it was about time I provided an Image List control to support them, so you do
....Read More |
Rating
|
|
|
Emulating Modal Forms
|
Total Hit (1034) |
Sometimes, the restrictions applied when showing a modal form can be restrictive. For example, if your application can have more than one main view window, a modal dialog prevents any other form from being activated whilst the modal dialog is displayed. Another example occurs when you want to try an
....Read More |
Rating
|
|
|
Creating and Responding to System-Wide Hotkeys
|
Total Hit (2044) |
Win32 allows you to set up combinations of key-presses which can be associated with an application on a system-wide scope, called Hotkeys. When a user presses a registered HotKey it doesn't matter which application is active when they pressed it, the hot-key message will get routed to your applicati
....Read More |
Rating
|
|