|
|
|
|
|
IsFormModal - Determines whether a form is modal
|
Total Hit (2146) |
«Code LangId=1»
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
Const GWL_STYLE = (-16)
Const WS_DISABLED = &H8000000
' Return True if the form is modal
'
' Note: if an application has only one visible
'
....Read More |
Rating
|
|
|
GetFiles - Returns all the files in a directory
|
Total Hit (1712) |
«Code LangId=1»' Returns a collection holding all the filenames that
' match a given filespec and search attributes.
Function GetFiles(filespec As String, Optional Attributes As VbFileAttribute) _
As Collection
Dim filename As String
Set GetFiles = New Collection
....Read More |
Rating
|
|
|
SetFileSize - Trim or extend a file's size
|
Total Hit (2719) |
«Code LangId=1»
Option Explicit
Private Declare Function CreateFile Lib "kernel32" Alias "CreateFileA" (ByVal _
lpFileName As String, ByVal dwDesiredAccess As Long, _
ByVal dwShareMode As Long, lpSecurityAttributes As Any, _
ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAt
....Read More |
Rating
|
|
|
|
Dec2Any - Convert a decimal number to any other base
|
Total Hit (3273) |
«Code LangId=1»' convert a number to any base
' BASE can be in the range 2-36
Function Dec2Any(ByVal number As Long, ByVal base As Integer) As String
Dim index As Long
Dim digits As String
Dim digitValue As Long
' check base
If base < 2 Or base > 36 Then Err.Raise
....Read More |
Rating
|
|
|
CompareValue - Check whether a value is in a list of values
|
Total Hit (1895) |
«Code LangId=1»' Compares a numeric or string value with a list of other values.
' Returns the 1-based index of the matching value, or zero if the
' value doesn't appear in the list.
' String comparisons are case-sensitive.
'
' This function can conveniently replace a Select Case or a list
'
....Read More |
Rating
|
|
|
Retrieve the length of a media file (WAV, AVI, MIDI)
|
Total Hit (5751) |
You can retrieve the length of a standard windows media file (WAV, AVI or MIDI) using simple MCI functions. First, you must open the file with:
«Code LangId=1»
Declare Function mciSendString Lib "winmm" Alias "mciSendStringA" (ByVal _
lpstrCommand As String, ByVal lpstrReturnString As Strin
....Read More |
Rating
|
|
|
Always ensure that a printer is installed
|
Total Hit (2910) |
Many developers incorrectly assume that a printer is always installed on their customers' machines, and therefore omit to check that this is actually the case. The following function, deceiptively trivial, returns False and displays an error message if no printer has been installed:
«Code LangId=
....Read More |
Rating
|
|
|
Don't pass Private objects to client applications
|
Total Hit (2912) |
Under some circumstances, an ActiveX DLL can pass private objects to its client application, for example a reference to a control that belongs to a form in the DLL. While this approach can be useful, and can work under some circumstances, you should absolutely avoid avoid to do so, because it might
....Read More |
Rating
|
|
|
Changing the current record using bookmarks
|
Total Hit (2492) |
If you try to use a DataList and some labels or text boxes linked to an ADO Data control, and you click on some items in the list, you'll notice that the data in the labels won't change, because the current record isn't changed.
To have the code work correctly, you have to write code in the Clic
....Read More |
Rating
|
|
|
Unload a form with shrinking effect
|
Total Hit (1648) |
A simple way to add some pizazz to your forms is by minimizing them and then closing them, instead of making them disapper istantaneously. Just try this code:
«Code LangId=1»
Private Sub Form_Unload(Cancel As Integer)
Me.WindowState = vbMinimized
End Sub
«/Code»
....Read More |
Rating
|
|
|
Change the width of the dropdown portion of a ComboBox
|
Total Hit (3358) |
The ComboBox control doesn't expose any property that lets you to control the width of its list area, but this can be easily accomplished by sending it the CB_SETDROPPEDWIDTH message, and passing the new length in pixel in wParam:
«Code LangId=1»
Private Declare Function SendMessage Lib "user32"
....Read More |
Rating
|
|
|
Evaluate the number of days remaining in the current year
|
Total Hit (2935) |
The DatePart() function can return the number of days from the beginning of the current year, but there is no VB built-in function that returns the number of days left to the end of the year. You can work around this with the DateDiff function:
«Code LangId=1»
' aDate contains a valid date
Days
....Read More |
Rating
|
|
|
REMark out a group of lines
|
Total Hit (4416) |
VB5 and VB6 environments include a pair hidden commands that let you remark and unremark a group of statements. These commands are hidden in the sense that they can be found on the secondary Edit toolbar that isn't displayed by default. To make these commands available, right-click anywhere on the m
....Read More |
Rating
|
|
|
|
|
How to display different control panel applets
|
Total Hit (3311) |
«code LangId=1»' Display the Control Panel
Call Shell("rundll32.exe shell32.dll,Control_RunDLL", vbNormalFocus)
'Display the Accessibility Properties
Call Shell("rundll32.exe shell32.dll,Control_RunDLL access.cpl", vbNormalFocus)
'Display Add/Remove Programs
Call Shell("rundll32.exe shell32
....Read More |
Rating
|
|
|
|
How to Obtain the Serial Number of a Drive...
|
Total Hit (1690) |
API Declarations
«Code LangId=1»
'API Declarations
Private Declare Function GetVolumeSerialNumber Lib "kernel32.dll" Alias "GetVolumeInformationA" (ByVal lpRootPathName As String, ByVal lpVolumeNameBuffer As String, ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, lpMaximumComponent
....Read More |
Rating
|
|
|
The vbip.com FtpClient source code library
|
Total Hit (1952) |
The FtpClient library is a set of the code and class VB modules that provides the VB developers with the tool for implementing FTP client functionality into their applications. This is not the old ugly CFtpConnection class (that by the way is still available for download). The main module of the lib
....Read More |
Rating
|
|
|
Creation of an Access database from an XML file
|
Total Hit (1158) |
This class was originally part of a larger project to extract data from a mainframe and present it to Crystal Reports. I selected XML as the data format because it is so flexible and yet easy to generate from COBOL. The code to transport the data from the mainframe and generate the reports has been
....Read More |
Rating
|
|
|
Unzipping files using the free Info-Zip Unzip DLL with VB
|
Total Hit (1880) |
This article provides a fully featured unzip application written in VB, using the capabilities of the Info-ZIP Unzip DLL. The zip application demonstrates the abilities of the unzip DLL to handle all aspects of unzip operations - password protection, directory listing, including directories whilst u
....Read More |
Rating
|
|
|
HTTP file upload from VB
|
Total Hit (3107) |
This ActiveX control allows users to submit a file to a Web server. This component uses the WinSocket control to submit files using the file transfer protocol (FTP). It only worked in Internet Explorer 3.02 and higher, and several clients used Netscape, so I had to find another solution.
....Read More |
Rating
|
|
|
Duplicating the Contents of a Treeview
|
Total Hit (1437) |
The three routines below combine to produce an effective way to duplicate a TreeView with all its data. No API is used, yet the method executes quite quickly. To maximize speed when copying large treeviews, set the receiving treeview's visible property to False before beginning the copy.
The meth
....Read More |
Rating
|
|
|
Obtaining AVI File Information via API
|
Total Hit (2483) |
This routine shows a couple of things. First and foremost, it details how to retrieve AVI file information from the AVI file using the AVIFileOpen the AVIGetFileInfo APIs. It also shows how to populate a ListView with this information, how to determine the Time Scale for the AVI, and how to use this
....Read More |
Rating
|
|
|
vbAccelerator Progress Bar Control
|
Total Hit (1532) |
This control provides a highly flexible Progress Bar control with an array of drawing styles, including XP Style, segmented/non-segmented, bitmap bars and backgrounds and more. Alternatively, if you don't want the convenient packaging and design-time property settings provided by a control, you can
....Read More |
Rating
|
|