|
|
|
|
|
Right Click PopUp Menu
|
Total Hit (1537) |
«Code LangId=1»'First, create a menu using menueditor. Add all of your menu items as if you were just making
'a regular menu. Now set the VISIBLE property of the main menu item to false (see below, set
'the MNUEDIT item's VISIBLE to false). Like this:
'mnuEdit
'---mnuUndo
'---mnuRedo
'---m
....Read More |
Rating
|
|
|
Filter - A replacement for VB6's Filter function under VB5
|
Total Hit (2118) |
«Code LangId=1»' A replace for the Filter function under VB4 and VB5
'
' Note that the source array is modified. For this reason
' this is declared as a Sub rather than a Function
Sub Filter(arr() As String, ByVal Search As String, Optional ByVal Include As _
Boolean, Optional ByVal Comp
....Read More |
Rating
|
|
|
|
|
|
|
Cascade all the child windows of a window
|
Total Hit (3147) |
The Windows API provides an handy function that lets you cascade all the child windows of another window with one single call. The effect of this function is similar to the Cascade Windows command in most MDI apps, except the parent window doesn't have to be an MDI window.
This is the (incorrect)
....Read More |
Rating
|
|
|
Send HTML Email via CDO
|
Total Hit (4053) |
Ever wonder how to send email that looks like a web page? Here is how you do it. Note: You must have CDO for NT referenced for this to work.
«Code LangId=1»
'Sends an email to the appropriate person(s).
'
'From = Email address being sent from
'SendTo = List of email addresses separated by a s
....Read More |
Rating
|
|
|
Don't hard-code font names and size
|
Total Hit (1715) |
Unless you have good reason to do otherwise, you should always use standard fonts in your programs, because this ensures that your application will work on every Windows system.
If you want to use non-standard fonts, you should at least adopt the following guidelines:
«Code LangId=1»
Assign
....Read More |
Rating
|
|
|
The number of days in a month
|
Total Hit (3787) |
You need just one-line function to evaluate the number of days in a month (while taking leap years into account, of course). The trick is to use the DateDiff and DateSerial functions to calculate the difference between the first day of the current month and the first day of the subsequent month :
....Read More |
Rating
|
|
|
Counting Bits
|
Total Hit (3225) |
It seems that the only way to count the number of 1's or 0's in a binary value is creating a loop that iterates on all the 16 or 32 bits of the number. There is, however, a faster algorithm:
«Code LangId=1»
Function BitCount (ByVal number As Long) As Integer
Dim bits As Integer, temp As Long
....Read More |
Rating
|
|
|
Retrieve the currency symbol
|
Total Hit (3053) |
It is very simple to retrieve the correct currency symbol, using just plain VBA statements:
«Code LangId=1»
currSymbol = Trim$(Replace(FormatCurrency(0,0), "0", ""))
«/Code»
If you can also determine if the symbol precedes or follows the currency amount using this method: «Code LangId=1»
If
....Read More |
Rating
|
|
|
Write concise code: a collection of simple tips
|
Total Hit (2118) |
If you fully understand how VB and VBA work, you can often save some statements. This makes your listings more concise and more readable, and indirectly optimizes your program. Here is a short list of the many tricks you can use with this goal. You don't need to initialize a numeric variable to 0 or
....Read More |
Rating
|
|
|
How to use BeginPath and EndPath to fill open shapes.
|
Total Hit (4326) |
Have you ever tried to fill shapes which are drawn by Polyline or PolyBezier which doesn't draw closed figures. The problem is its not closed figure so you cannot fill using regular fill method which works very well with closed figures. The solution to this problem is BeginPath and EndPath apis
Y
....Read More |
Rating
|
|
|
|
Using the GetSaveFileName Common Dialog API
|
Total Hit (1431) |
This page provides the code required for the Common Dialog GetSaveFileName API method. OPENFILENAME member descriptions, as well as commented code, are covered in the pages above. Except for the Flags and API name, the code is pretty well a duplicate of the GetOpenFileName code.
....Read More |
Rating
|
|
|
How to Determine Selected ListItems
|
Total Hit (1287) |
A quick routine to demonstrate using SendMessage with LVM_GETSELECTEDCOUNT and LVM_GETNEXTITEM messages to traverse a listview to retrieve the indices to the selected items in a MultiSelect control. Also contains a portion of the LVM_SUBITEMHITTEST code from How to Deselect ListItems on Clicking a L
....Read More |
Rating
|
|
|
Killing the Default Combo Box Context Menu
|
Total Hit (1126) |
For this to work we have to borrow from the combo method that deals with retrieving the handle to the edit portion of the control (see related topics above). The edit handle is stored, where it is compared to the hWnd passed by the WindowProc procedure. If the handle is that of the edit control, the
....Read More |
Rating
|
|
|
Change the drop-down width of a Combo Box
|
Total Hit (1981) |
This tip shows you how to get and set the width of the drop down portion of a combo box. It also includes code to automatically set the drop down width based on the contents of a combo box by measuring the size of the text in each combo box item.
|
Rating
|
|
|
Detecting Mouse XButton Clicks
|
Total Hit (2088) |
Recently I discovered that my mouse had two strange buttons on the left-hand side (until then I'd thought that the mouse's case just wasn't very well put together). Turns out these are the 'X Buttons' and can be used for moving backwards and forwards in Explorer and IE. This sample demonstrates how
....Read More |
Rating
|
|
|
vbAccelerator S-Grid Control
|
Total Hit (2275) |
The SGrid control is an all-VB grid which can emulate the Outlook messages list, including grouping of messages and message preview. The highly optimised display code makes this grid draw faster than FlexGrid and other VB grids even while it allows more sophisticated displays to be set up. It is als
....Read More |
Rating
|
|
|
|
Adding Scroll Bars to Forms, PictureBoxes and User Controls
|
Total Hit (2433) |
In the Win32 API, all windows can have scroll bars. However, this feature is not exposed in any way in Visual Basic. Its not too hard to enable, though provided you can intercept WM_HSCROLL and WM_VSCROLL messages sent to the window. This project provides a small, self-contained class which extends
....Read More |
Rating
|
|
|
Making VB Apply XP Visual Styles at Design and Debug Time
|
Total Hit (1412) |
If you want to use XP Visual Styles in a VB application, the fact that the controls don't draw using the new styles at design- or debug-time can be a problem, as your form looks different when once you've compiled. Luckily you can persuade both VB5 and VB6 IDEs to use XP Visual Styles too.
....Read More |
Rating
|
|
|
Common Dialog Templates - Create a WinZip Style File Add Dialog
|
Total Hit (1073) |
This sample, from Cayce Cochran (cayce@fastlane.net), demonstrates how to use a dialog template with a File Open or Save CommonDialog. It takes advantage of the CommonDialog/Direct DLL component which now (versions dated 1 November 1999 and higher) includes the relevant support for templates.
....Read More |
Rating
|
|
|