|
...and how to change the name of your computer...
|
Total Hit (2957) |
API Declarations
«Code LangId=1» Private Declare Function SetComputerName Lib "kernel32.dll" Alias "SetComputerNameA" (ByVal lpComputerName As String) As Long
«/Code»
Module «Code LangId=1»
Public Function SetComputerName(Name as String) as Boolean
Dim res As Long
res=SetCo
....Read More |
Rating
|
|
|
|
|
|
|
|
|
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
|
|
|
GetStringBetweenTags - Returns a string between 2 delimiters
|
Total Hit (3105) |
«Code LangId=1»' Returns a string between 2 delimiters
' Parameters:
' sSearchIn: String to search
' sFrom: First keyword
' sUntil: Second keywords
' nPosAfter: Gets the position after
'
' Example:
' Debug.Print GetStringBetweenTags("<html>This is a sample of title</html>",
'
....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
|
|
|
Hide or disable the desktop icons
|
Total Hit (3621) |
The Desktop is a window like any other window in the system, so you can hide/show and enable/disable it. The only details you need to know is how to retrieve the handle to the Desktop window. It turns out that this window is the first child window of the "Program Manager" window, so all you need is
....Read More |
Rating
|
|
|
Determine whether a control has a scrollbar
|
Total Hit (2849) |
There is no built-in VB function that lets you know whether a control - such as a ListBox - is currently displaying a vertical scrollbar. Here's a pair of functions that check the control's style bits and return a Boolean that tells if a vertical or horizontal scrollbar is visible:
«Code LangId=1
....Read More |
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
|
|
|
Write concise code with the Switch function
|
Total Hit (1781) |
Many VB developers don't realize that the Switch built-in function can often save a lot of code. This function takes any number of (expr, value) pairs, it evaluates all expressions and return the value related to the first expression that is found to be True. Typically you can use a Switch function
....Read More |
Rating
|
|
|
Manufacture a Missing value
|
Total Hit (3949) |
Visual Basic doesn't provide you with a means for creating a Missing value, a feature that in some cases would prove useful in order to simplify the syntax of calls to procedures that expects a variable number of arguments. It isn't difficult, however, to create such a value programmatically, as fol
....Read More |
Rating
|
|
|
Getting StdPicture's Width and Height properties in Pixels
|
Total Hit (5135) |
In general, Visual Basic doesn't provide a way to determine the size of a bitmap loaded into a PictureBox control. But you can derive this information if you set the control's AutoSize property to True and then read the control's ScaleWidth and ScaleHeight properties. If you don't want to resize a v
....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
|
|
|
|
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
|
|
|
Disabling the Combo Edit Box
|
Total Hit (1441) |
OK, so you have a combo (Style 0) where you want to allow the user the ability to copy the contents, but not change the text. Setting the combo's locked property will do the trick, but the right-mouse context menu is still available. This shows how using FindWindowEx and SendMessage with the EM_SETR
....Read More |
Rating
|
|
|
Creating a Custom PhotoShop-Style ProgressBar in a MDI App
|
Total Hit (1020) |
The routine here is based on code originally developed to overcome some of the display limitations of the original VB3 SSPanel FloodPercent control, namely justification of text and positioning as a member inside a status panel. The routine was originally developed in VB3, and has been updated for u
....Read More |
Rating
|
|
|
Presenting a Non-Selectable 'No Data' Picture in a ListBox
|
Total Hit (1718) |
The VBnet page Customizing the ListView's Appearance via API showed how to use SendMessage with the LVBKIMAGE structure to display images in the data window of a listview control. Although Windows' normal list box does not support such functionality, we can still fake this functionality using the B
....Read More |
Rating
|
|
|
|
|
Adding, Deleting and Viewing Recent Documents
|
Total Hit (1055) |
This sample demonstrates how to add, read and clear the Shell's Recent Document List from VB code. At the same time, it provides a useful ShellLink class for working with Shortcuts.
|
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
|
|
|
Animated Cursors in VB
|
Total Hit (1853) |
Nice feature in Office - you can set it to show customised animated cursors. For example, when Office is opening a document the cursor switches to an animation of a yellow handbag throwing up a small piece of paper (I think that's what it is, anyway).
It would be nice to do it this in VB too, yes
....Read More |
Rating
|
|
|
|
CommonDialog/Direct
|
Total Hit (3077) |
Common Dialog/Direct is a new DLL or class library which shows how to completely replace COMDLG32.OCX through Visual Basic code. The main advantage of this is you no longer need to put a control on a form to use common dialogs - just declare an instance of the class and you have a straight replaceme
....Read More |
Rating
|
|