|
|
|
|
|
|
|
GetFilePath - Extract the path portion of a file name
|
Total Hit (3939) |
«Code LangId=1»
' Retrieve a file's path
'
' Note: trailing backslashes are never included in the result
Function GetFilePath(FileName As String) As String
Dim i As Long
For i = Len(FileName) To 1 Step -1
Select Case Mid$(FileName, i, 1)
Case ":"
....Read More |
Rating
|
|
|
|
IsValidDateField - Check whether a date is valid
|
Total Hit (3495) |
«Code LangId=1»Enum psDateTypes
AnyValidDate 'Allows any valid date to be entered
PastDate 'Only allows past dates (before today) to be entered
FutureDate 'Only allows future dates (after today) to be entered
TodayOrFuture 'Only allows today or future date to be
....Read More |
Rating
|
|
|
Crc16 - Evaluate the 16-bit CRC of an array of bytes
|
Total Hit (4731) |
«Code LangId=1»Option Explicit
' Evalutate the 16-bit CRC (Cyclic Redundancy Checksum) of an array of bytes
'
' If you omit the second argument, the entire array is considered
Function Crc16(cp() As Byte, Optional ByVal Size As Long = -1) As Long
Dim i As Long
Dim fcs As Long
Static
....Read More |
Rating
|
|
|
Windows Installer Appears Every Time I Start an Application
|
Total Hit (4729) |
Intended For
Windows XP
Windows 2000
The Windows Installer is a global application used to install many Microsoft products, including Office 2000 and Office XP, and is even available to third-party developers to include with their programs.
Unfortunately, it's fraught with bugs, one of
....Read More |
Rating
|
|
|
Never use the GetLastError API function
|
Total Hit (3922) |
If you heavily use API calls and strictly follow the SDK documentation, you might be tempted to use the GetLastError API to retrieve the error returned by your last API function or procedure. However, this function doesn't always return valid error codes, because Visual Basic internally does a lot o
....Read More |
Rating
|
|
|
Swap the mouse buttons' behavior and meaning
|
Total Hit (4193) |
You can programmatically swap the meaning of the left and right mouse buttons, to account for your left-handed users. All you need is a call to the SystemParameterInfo API function
«Code LangId=1»
Private Declare Function SystemParametersInfo Lib "user32" Alias _
"SystemParametersInfoA" (By
....Read More |
Rating
|
|
|
Make a phone call using TAPI
|
Total Hit (4844) |
If TAPI libraries are installed on your machine, you can easily dial a number from a VB application using a single API call. Here's a function that encapsulates the call and that returns True if the dialing was successful:
«Code LangId=1»
Private Declare Function tapiRequestMakeCall Lib "TAPI32.
....Read More |
Rating
|
|
|
Don't include Extender properties in ActiveX Wizard
|
Total Hit (3219) |
The left-most listbox in the first page in the ActiveX Control Interface Wizard includes all the properties exposed by the constituent controls currently on the UserControl's surface. Unfortunately, this list includes Extender properties, methods, and events, which should be never added to the publi
....Read More |
Rating
|
|
|
A template for building collection class modules
|
Total Hit (3691) |
The following is a template for building collection class modules in a very quick and effective way. Copy-and-paste this code into Notepad, that save it to a file named "COLLECTION CLASS.CLS" in the \TEMPLATE\CLASSES subdirectory under the main VB6 directory:
«Code LangId=1»
VERSION 1.0 CLASS
B
....Read More |
Rating
|
|
|
Ensure that a form's TextBox and ComboBox controls have same height
|
Total Hit (3302) |
In general you don't have any control on a ComboBox's Height property, because it is determined automatically by VB depending on the font used for the ComboBox control. If you have a form that contains both TextBox and ComboBox controls, you should ensure that all your single-line TextBox controls a
....Read More |
Rating
|
|
|
Change the ShowInTaskbar property at runtime
|
Total Hit (4484) |
The ShowInTaskbar property lets you decide whether a form is visible in Windows taskbar or not. However, this property is read-only at runtime, so it seems that you can't change this setting while the program is running. Luckly, you just need to change the window's style, using a pair of API functio
....Read More |
Rating
|
|
|
Reduce the number of DoEvents
|
Total Hit (4606) |
Don't fill your code with unnecessary DoEvents statements, especially within time-critical loops. If you can't avoid that, at least you can reduce the overhead by invoking DoEvents only every N iterations of the loop, using a statement like this:
«Code LangId=1»
If (loopNdx Mod 10) = 0 Then DoEv
....Read More |
Rating
|
|
|
Guitar simulation using MIDI APIs
|
Total Hit (6005) |
«b»Step-By-Step Example«/b»
- Create a standard exe project
- Add one listbox, combobox and 2 command button controls
- Add one class module and rename it to clsMIDI
- Add the following code in form1
«b»Form1.frm«/b»
«code LangId=1»Dim objMIDI As New clsMIDI
Private Enum enumInstruments
....Read More |
Rating
|
|
|
Working with Meta Files (EMF,WMF and APM)
|
Total Hit (12494) |
A metafile is a mechanism for storing a graphics device interface (GDI) "picture"—a series of GDI functions that are used to draw an image. A metafile consists of a series of records, each representing a GDI function. When the metafile is played back, each stored function is executed using its recor
....Read More |
Rating
|
|
|
How to display API Error Description.
|
Total Hit (4116) |
When you execute any system API generally it returns success/failure using return value. To find out any error you have to use GetLastError api or Err.LastDllError property of Err object in VB. But it will return only ErrorCode not description. You can use following code to get description of API Er
....Read More |
Rating
|
|
|
Another check if a file exists
|
Total Hit (2928) |
«Code LangId=1»Function FileExists(strFile As String) As Integer
'********************************************************************************
'* Name : FileExists
'* Date : Feb-17, 2000
'* Author : David Costelloe
'* Returns : -1 = Does not exists 0 = Exists with zero bytes 1 = Exists > 0
....Read More |
Rating
|
|
|
|
|
Changing the Dropdown Width of a Combo Box
|
Total Hit (1213) |
This routine demonstrates using the API to change the width of the dropdown portion of a combo box. The combo list width is manually set in the accompanying text box.
|
Rating
|
|
|
Using the Joystick, Mouse and Keyboard
|
Total Hit (2266) |
So far we have learned how to move, animate and do some other stuff to sprites. We have also looked into the area of sound playback in games. This is all very nice if you want to create a game with no human interaction. Since this is most likely not the kind of game you want to make, then you need t
....Read More |
Rating
|
|
|
Forcing a local or remote NT system to reboot
|
Total Hit (2948) |
Under Windows NT, you can force a timed system shutdown on either the local machine or a remote network machine. This code tip shows how to do it. You can specifiy how long it will be before the machine will be shutdown in seconds (a zero value shuts down immediately), how remorseless the shutdown p
....Read More |
Rating
|
|
|
Create New GUIDs
|
Total Hit (2574) |
This sample, from Dion Wiggins (dionwiggins@hotmail.com) shows how to use the CoCreateGuid and StringFromGUID2 functions to create a GUID.
The code is compiled into an ActiveX DLL which gives the interesting possibility of using the code from an ASP page, or from other ActiveX-enabled scripting
....Read More |
Rating
|
|
|
Owner Draw Combo and List Boxes Version 2.1
|
Total Hit (1764) |
Owner draw combo and list boxes are an excellent way to improve the look and feel of your application. However, there is little support for them in Visual Basic. The only owner-draw combo box supplied is the Checked list box style, but this is a preset list box style with no possibility for customis
....Read More |
Rating
|
|