|
|
|
|
|
|
|
ReadFromStdInput - Read from standard input stream
|
Total Hit (3551) |
«Code LangId=1»Private Declare Function GetStdHandle Lib "kernel32" (ByVal nStdHandle As Long) _
As Long
Private Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, _
lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, _
lpNumberOfBytesRead As Long, lpOverlapped As Any)
....Read More |
Rating
|
|
|
NumberToWords - Convert a number into its string representation
|
Total Hit (1929) |
«Code LangId=1»
' Convert a number into its textual equivalent.
'
' Pass True in the second argument if you want a null string when
' zero is passed.
' This is a recursive routine that is probably the most concise
' routines that solves the problem
Function NumberToWords(ByVal Number As L
....Read More |
Rating
|
|
|
RotateLeftI - Rotate an Integer to the left
|
Total Hit (1852) |
«Code LangId=1»' Rotate an Integer to the left the specified number of times
'
' NOTE: requires Power2()
Function RotateLeftI(ByVal value As Integer, ByVal times As Long) As Integer
Dim i As Long, signBits As Integer
' no need to rotate more times than required
times = time
....Read More |
Rating
|
|
|
EncryptString - Encode and decode a string
|
Total Hit (3288) |
«Code LangId=1»
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As _
Any, source As Any, ByVal bytes As Long)
' encrypt a string using a password
'
' you must reapply the same function (and same password) on
' the encrypted string to obtain the original, non-enc
....Read More |
Rating
|
|
|
|
BitTest - Test the value of a bit
|
Total Hit (3627) |
«Code LangId=1»' Test the value of a bit
'
' NOTE: requires Power2()
Function BitTest(ByVal value As Long, ByVal bit As Long) As Boolean
' simply AND with the bit mask
' Range checking is performed in Power2()
BitTest = (value And Power2(bit))
End Function
' Raise 2 to a po
....Read More |
Rating
|
|
|
Misconceptions on variables and binding
|
Total Hit (1881) |
Consider this line of code:
Dim x as Project1.Class1
Many developers think that we were declaring x as a "Project1.Class1" object. This is wrong. All object variables in VB are interface variables. In this line of code x is declared as the _Class1 interface defined in the Project1 Type librar
....Read More |
Rating
|
|
|
Get the Windows temporary directory (without any API call)
|
Total Hit (3203) |
The usual way to determine the Windows' main directory is based on the GetTempPath API function, which requires that you set up a buffer for the result, and then extract the null-terminated result. However, there is a much simpler approach, that works equally well under Windows 95, 98 and NT. It is
....Read More |
Rating
|
|
|
Play an AVI movie in a PictureBox control
|
Total Hit (5390) |
With MCI functions you can play an AVI movie into a PictureBox. All you need to do is open the file with a special procedure:
«Code LangId=1»
Declare Function mciSendString Lib "winmm" Alias "mciSendStringA" (ByVal _
lpstrCommand As String, ByVal lpstrReturnString As String, _
ByVal uR
....Read More |
Rating
|
|
|
Add a file to the list of recent documents
|
Total Hit (2971) |
The Windows shell provides a function that lets you add a file to the list of the recent documents, that is the list that you can access from the Start menu:
«Code LangId=1»
Private Declare Function SHAddToRecentDocs Lib "shell32.dll" (ByVal dwFlags As _
Long, ByVal dwData As String) As Lon
....Read More |
Rating
|
|
|
Add an horizontal scrollbar to a ListBox control
|
Total Hit (4861) |
By default, VB ListBox controls don't display an horizontal scrollbar, so if the items you add to the controls are wider than the control's Width, the end user isn't able to read them in their entirety.
Adding an horizontal scrollbar to a ListBox control is easy, however. You only have to increas
....Read More |
Rating
|
|
|
Avoid Integer Overflow
|
Total Hit (2997) |
When working with integer expressions there is often the risk of raising the "Overflow" error. More specifically, there can be two occasions when this frequently occurs:
When you multiply or add Integer values and the result exceeds 32,767.
When you create generic string routines that iterate
....Read More |
Rating
|
|
|
Write concise code with the InStr function
|
Total Hit (2122) |
You can often use the Instr function in an unorthodox way to write more concise code. A typical example is when you need to test a single character:
«Code LangId=1»
' test whether CHAR contains a vowel
' the standard way
If UCase$(char) = "A" Or UCase$(char) = "E" Or UCase$(char) = "I" Or UCas
....Read More |
Rating
|
|
|
LenB has changed from VB5 to VB6
|
Total Hit (4434) |
Visual Basic stores UDTs in unpacked format, that is it alignes all UDT elements to the double word (except that Integers and Boolean are aligned to the word, and byte elements aren't aligned at all). To keep the elements aligned VB adds padding bytes where necessary. For instance the structure:
«
....Read More |
Rating
|
|
|
|
WMI : Retrive extended information about processor
|
Total Hit (3322) |
Windows Management Instrumentation (WMI) makes Windows extremely manageable using a single consistent, standards-based, extensible and object-orientated interface. WMI is the Microsoft implementation of Web-Based Enterprise Management (WBEM), an industry initiative to develop a standard technology f
....Read More |
Rating
|
|
|
How to Create Constants and DLL Declarations in a Type Library
|
Total Hit (1694) |
It can be very useful to package constant definitions and DLL declarations in a type Library. Visual Basic allows you to access type libraries and their contents. Once you have made a reference to the type library, you can view its information in Visual Basic's own Object Browser. Type Libraries are
....Read More |
Rating
|
|
|
How to Add Images to a ListView Header
|
Total Hit (986) |
In most Windows applications, a visual indication of the sorting direction of the currently active listview column header is indicated by an up or down arrow. This functionality has previously been unavailable to the Visual Basic developer. The method detailed here demonstrates the steps to add your
....Read More |
Rating
|
|
|
|
Creating a Custom PhotoShop-Style ProgressBar
|
Total Hit (1005) |
The routines on this page were originally developed to overcome display limitations of the original VB3 SSPanel FloodPercent control, namely use of and justification of text and the positioning the control as a member of a status panel. The routine was originally developed in VB3 and has been update
....Read More |
Rating
|
|
|
Working with Multiple Monitors
|
Total Hit (2932) |
Windows 98/2000 systems and above provide support for multiple monitors. This is a great thing except that it messes up old programs which attempt to do things like centre Windows or otherwise restrict their position to the visible area of the screen. This tip provides some simple code to allow you
....Read More |
Rating
|
|
|
Perlin Noise
|
Total Hit (1668) |
Perlin Noise, named after its inventor Ken Perlin, is a widely used texturing primitive in two- and three- dimensional image creation. The Perlin Noise function generates a smoothly interpolated space of pseudo-random values which can be used as the basis for the procedural generation of realistic n
....Read More |
Rating
|
|
|
Creating Single Pixel Dotted Lines
|
Total Hit (1665) |
One of the drawing features which makes many of the Windows controls draw attractively is the use of single pixel on-off dotted lines. For example, the TreeView control uses these to draw lines, and they are often used in bounding box selections and drag and drop operations.
Unfortunately VB does
....Read More |
Rating
|
|
|
Using the Find and Replace Common Dialogs
|
Total Hit (2794) |
VB has never provided direct support for the Find/Replace common dialogs. This may have been because these dialogs are non-modal, and it is more difficult to use these from an ActiveX control container, or that it is fairly simple to knock up your own Find/Replace form in VB without bothering with t
....Read More |
Rating
|
|