|
|
|
|
|
|
|
|
|
ShortPathName - Convert a long file name to 8.3 format
|
Total Hit (3246) |
«Code LangId=1»Private Declare Function GetShortPathName Lib "kernel32" Alias _
"GetShortPathNameA" (ByVal lpszLongPath As String, _
ByVal lpszShortPath As String, ByVal cchBuffer As Long) As Long
Const MAX_PATH = 260
' Convert a long file/path name to a short 8.3 name
' the path m
....Read More |
Rating
|
|
|
|
LCM - The Least Common Multiple of two integers
|
Total Hit (3296) |
«Code LangId=1»' the Least Common Multiple of two integers
' (it uses the Euclide's algorithm)
' if either argument is zero you get a "Division by Zero" error
'
' Note: if your app also includes the CGD() function,
' you can simplify the following code as follows:
' LCM = (n1 * n2)
....Read More |
Rating
|
|
|
Power2 - A power of 2
|
Total Hit (1741) |
«Code LangId=1»
' Raise 2 to a power
' the exponent must be in the range [0,31]
Function Power2(ByVal exponent As Long) As Long
Static res(0 To 31) As Long
Dim i As Long
' rule out errors
If exponent < 0 Or exponent > 31 Then Err.Raise 5
' initialize the arr
....Read More |
Rating
|
|
|
Sending Email Using CDO and MAPI
|
Total Hit (4020) |
Sending emails via code used to be cool, but now it is a necessity. Below is code to send email via CDO. If the CDO call fails, it will send using MAPI. NOTE: You must have CDO for NT referenced in your project for this to work.
«Code LangId=1»
' Sends an email to the appropriate person(s)
'
'
....Read More |
Rating
|
|
|
Register and unregister type libraries
|
Total Hit (3603) |
All COM-oriented VB developers know how to register and unregister an ActiveX DLL, using the REGSVR32 utility. However, there is no such an utility to register and unregister a type library.
You can quickly build your own TLB Registration utility with a handful of statements, thanks to the undoc
....Read More |
Rating
|
|
|
Print the WebBrowser's contents
|
Total Hit (2809) |
The WebBrowser control doesn't expose any method to directly print its contents. You can achieve this effect through the ExecWB method, by passing the OLECMDID_PRINT constant in its first argument:
' display the Print dialog
WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER
You can
....Read More |
Rating
|
|
|
Use Refresh, not DoEvents
|
Total Hit (1914) |
The DoEvent statement should be used only to give other portions of your program to be reactive to the end user's actions. Instead, many VB developers use it to force a repaint of a form or some of its controls. This means adding a lot of overhead to your code, which you can avoid by using the Form'
....Read More |
Rating
|
|
|
How to Paint a ScanBar CODE39 on Printer or PictureBox
|
Total Hit (2799) |
«Code LangId=1»'Put this code at a module.
'Usage: PaintCodeBar39 Printer, Xpos, Ypos, BarsHeight, WidthFactor, Text, HumanRead
' Printer.EndDoc
Public Type C39
char As String * 1
bar(1 To 5) As Boolean
spe(1 To 5) As Boolean ' 5th space for character gap
End Type
Dim CODE39(
....Read More |
Rating
|
|
|
Undocumented Shell Path APIs (Testing Path).
|
Total Hit (4229) |
Way back when Microsoft released Internet Explorer 4.0, they bundled with it a number of upgrades to the operating system including a new DLL called SHLWAPI.DLL (Shell Lightweight Utility APIs). That DLL provided programmers with some useful path manipulation functions (amongst other things), but ob
....Read More |
Rating
|
|
|
Give user ability to interrupt loop
|
Total Hit (2777) |
Private Declare Function GetAsyncKeyState Lib "user32.dll" _
(ByVal vKey As Long) As Integer
'//ESCAPE
Const VK_ESCAPE = &H1B
'//Button Click
Const VK_LBUTTON = &H1
'//Interrupting A Do Loop
'//Give user ability to interrupt loop
Private Sub cmdStart_Click()
....Read More |
Rating
|
|
|
|
Listening for and accepting connection requests
|
Total Hit (2740) |
What the title of this article is talking about? Who is listening? Why should it accept any requests? To answer these questions just imagine that you are going to develop a server application that servers one or many client applications via a network. You'll find out that you know nothing about how
....Read More |
Rating
|
|
|
Hooking the Open & Save Common Dialogs To Manipulate Components
|
Total Hit (1422) |
Now that you're an expert at centering a common dialog using hooks its time to look at customizing other aspects of the dialog window. A frequent request is a method to set custom captions for the various buttons and static fields (labels) on the dialog. This page addresses this request.
Again the
....Read More |
Rating
|
|
|
Obtaining the Combo Box Edit Window Handle
|
Total Hit (1434) |
This method shows how you can obtain the handle to the edit portion of a combo box using the FindWindowEx API. Unlike the GetComboBoxInfo method linked above, this method will work with all versions of Windows 95/98/NT4/2000/XP so far released.
As a further check against the handle returned, you c
....Read More |
Rating
|
|
|
Creating a Transparent Bitmap
|
Total Hit (1461) |
Start a new project, and to the form add two controls - a single command button and a single PictureBox containing the picture to make transparent (Source), as shown in the illustration. The 'Transparent Result' in this example is displayed on the form's hdc, not in another picture or image control.
....Read More |
Rating
|
|
|
RunTime Debug Tracing
|
Total Hit (1952) |
Sometimes you want to be able to view trace messages when running your application outside the VB IDE. Perhaps something slightly different happens as an Executable; or you may be running something that's not so easy to debug, such as subclasses, callback procedures and custom COM implementations. W
....Read More |
Rating
|
|
|
Cellular Automata - Catalytic Reactions
|
Total Hit (840) |
This sample shows demonstrates a cellular automata which was initially designed to mimic catalytic reactions and in particular the Belousov-Zhabotinsky or "Clock" reaction. It produces a great variety of continuously varying, wave-like patterns.
|
Rating
|
|
|
vbAccelerator Drop-Down and Popup Form Control
|
Total Hit (1777) |
This control allows you to use any form as a drop-down window, and optionally to drag the form off and float it over the form. The form behaves just like the drop-down windows in Office, albeit you cannot currently dock them (yet!) The code includes a VB titlebar modifier class which ensures that an
....Read More |
Rating
|
|
|
vbAccelerator TreeView Control
|
Total Hit (1684) |
This article provides a new TreeView control that provides an alternative to the standard version provided with VB. Enhancements include much wider support for item colours and formatting, better drag-drop support including node auto-expand and scrolling, styles to support numbering items and an IE-
....Read More |
Rating
|
|
|
Shell an application and wait asynchronously for completion
|
Total Hit (2618) |
Surprisingly often it comes in handy to be able to shell another application and wait for it to complete. This sample shows what I think is the best way to do it. At least, this method has been totally reliable for me. Its better than some methods I have seen because the application isn't frozen whi
....Read More |
Rating
|
|
|
Reading and Saving .ICO files and resources in VB
|
Total Hit (2243) |
VB allows you to load an save .ICO files through the LoadPicture and SavePicture methods, which are implemented in the StdPicture object. Unfortunately, this object was really written for 16 bit Windows and doesn't understand Win32 icons at all. A .ICO resource can contain many different images, at
....Read More |
Rating
|
|