|
|
|
How to use Named Pipes in a Visual Basic 32-bit Program ?
|
Total Hit (12007) |
Visual Basic can create applications that communicate to other processes by means of Named Pipes. The Named Pipe must be created on Windows 2000 or Windows NT; however, you can read from and write to that pipe from any 32-bit platform.
This article demonstrates Client/Server communication using a
....Read More |
Rating
|
|
|
|
|
|
QuickSort - Sort Arrays using the QuickSort Algorithm
|
Total Hit (1802) |
«Code LangId=1»' QuickSort an array of any type
' QuickSort is especially convenient with large arrays (>1,000
' items) that contains items in random order. Its performance
' quickly degrades if the array is already almost sorted. (There are
' variations of the QuickSort algorithm that work goo
....Read More |
Rating
|
|
|
GetAttrDescr - The attributes of a file in a readable format
|
Total Hit (2685) |
«Code LangId=1»
' The attributes of a file in a readable format.
' It works also with open files, raises an error if the file doesn't exist.
Function GetAttrDescr(filename As String) As String
Dim result As String, attr As Long
' get file attributes as a bit-coded field
attr =
....Read More |
Rating
|
|
|
SplitWithQualifiers - An improved version of the Split function
|
Total Hit (2256) |
«Code LangId=1»' A variant of the Split function, that offers the following improvements
' You can pass text qualifier as the third argument and optionally specify
' to treat consecutive occurrences of delimiters as one
' For example, the following source text contains comma inside one of
....Read More |
Rating
|
|
|
FilterString - Remove invalid characters from a string
|
Total Hit (3235) |
«Code LangId=1»' Filter out all invalid characters in a string.
Function FilterString(text As String, ValidChars As String) As String
Dim i As Long, result As String
For i = 1 To Len(text)
If InStr(ValidChars, Mid$(text, i, 1)) Then
result = result & Mid$(text, i,
....Read More |
Rating
|
|
|
|
Download a file with one API call
|
Total Hit (3723) |
If you have Internet Explorer 5 or later version, you can use an API call to download a file from the Internet withouth displaying any message box.
«Code LangId=1»
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As Strin
....Read More |
Rating
|
|
|
Create explicit Field objects when looping on large Recordsets
|
Total Hit (2652) |
Whenever you access a database field through the Recordset object you incur in a slight overhead. Take for example the following code snippet:
«Code LangId=1»
Dim rs As New ADODB.Recordset
rs.Open "SELECT au_lname, au_fname FROM authors", "DSN=pubs", , , adCmdText
Do Until rs.EOF
List1.
....Read More |
Rating
|
|
|
Always declare objects with full library name
|
Total Hit (2923) |
If your application uses objects from external components, either third-party or your own libraries, a good rule of thumb is to include the complete servername.classname string in the Dim statement, as in:
«Code LangId=1»
Dim word As Word.Application
«/Code»
This syntax ensures that if you th
....Read More |
Rating
|
|
|
Move focus with Up and Down keys
|
Total Hit (1836) |
In all standard controls, Up and Down arrow keys move the focus on the previous or next control in the TabIndex order, respectively. This contrasts with text boxes, where these keys move the caret on the adjacent character, which you can achieve in a more natural way using the Left and Right cursor
....Read More |
Rating
|
|
|
Determine how a control got the focus
|
Total Hit (2392) |
At times it might be convenient to know how a given control got the focus, namely by means of the Tab key, an associated hotkey or a click of the mouse. You can learn this information through the GetKeyState API function, that returns the current state of a key. Here is a simple function that is mea
....Read More |
Rating
|
|
|
Use the right type for constants
|
Total Hit (3128) |
VB stores symbolic and literal constants internally using the simplest data type possible; this means that most common numeric constants-such as zero or one-are stored as Integers. If you use these constants in floating point expressions you can speed up your code using a constant of appropriate typ
....Read More |
Rating
|
|
|
Implement the CallByName function using the TLI library
|
Total Hit (5505) |
Thanks to the undocumented TlbInf32 library you can emulate the VB6 CallByName() function in VB5 too. First, add a reference to the "TypeLib Information" type library in your project. This library contains the InvokeHook function, which is very similar to CallByName.
Let's suppose you have an Act
....Read More |
Rating
|
|
|
Get the List of all the Active Tasks
|
Total Hit (3733) |
API Declarations
«Code LangId=1»
Option Explicit
' API Constants
Const WS_MINIMIZE = &H20000000 ' Style bit 'is minimized'
Const HWND_TOP = 0 ' Move to top of z-order
Const SWP_NOSIZE = &H1 ' Do not re-size window
Const SWP_NOMOVE = &H2 ' Do not reposition window
Const SWP_SHOWWINDOW = &
....Read More |
Rating
|
|
|
|
|
|
|
|
Highlighting a Listview Report Column
|
Total Hit (1605) |
Just as the picture property was used in Creating a Ledger-Style Listview Report Background to simulate a ledger-style background for the listview, this code provides a means to highlight the data in a specific column in the control using the same technique.
To do this, the the default background c
....Read More |
Rating
|
|
|
Creating a Common Control Progress Bar - Overview
|
Total Hit (1519) |
The following is an explanation of the messages and structures used by the Windows Progress Bar common control, written by Brad Martinez and provided for distribution on VBnet.
The Windows Common Controls API continues to grow as more features are added. Currently, comctl32.dll contains the follo
....Read More |
Rating
|
|
|
|
Compact a Long Path Name to fit a given space
|
Total Hit (1883) |
Often there is not enough room to display all of a long path name. A neat way to format a path name in a given space is to show some of the beginning of the path and the filename itself, whilst missing out some of the central folders and replacing them with ellipses (..) This method is used in many
....Read More |
Rating
|
|
|
HiWords and LoWords from Long Values
|
Total Hit (728) |
When translating C code to VB, you quite often come across the HiWord and LoWord operators, used to pack two integers into a long value. A simple translation of HiWord code will run into difficulties when unsigned integer arithmetic is being used in the C code and the highest bit of the long value c
....Read More |
Rating
|
|
|
vbAccelerator IconMenu DLL
|
Total Hit (1834) |
There are various controls for drawing menus with icons in at this site (and some code for doing the same sort of thing elsewhere). But so far these objects and code have been quite difficult to implement. This happens because these objects provide support for creating arbitrary menus at runtime - s
....Read More |
Rating
|
|