|
Print a Text File
|
Total Hit (2402) |
Module
«Code LangId=1» Option Explicit
Public Sub PrintTXTFile(FileName As String)
Dim x As Integer
Dim s As String
x = FreeFile
On Error GoTo HandleError
Open FileName For Input As x
Do While Not EOF(x)
Line Input #x, s
Printer.Print s
L
....Read More |
Rating
|
|
|
Print Dialogbox without using Common Dialogbox ActiveX control
|
Total Hit (4839) |
This code will show you use of PrintDialog API to show print dialogbox.
«b»Step-By-Step Example«/b»
- Create a standard exe project
- Add one class module
- Rename it to clsPrnDlg
- Add one command button on form1
- Place the following code in form1
«code LangId=1»Private Sub Command1_C
....Read More |
Rating
|
|
|
|
How to block/unblock keyboard and mouse input ?
|
Total Hit (5304) |
You can use BlockInput to block keyboard and mouse. Pass true to block and false to unblock keyboard and mouse.
«b»Step-By-Step Example«/b»
- Create a standard exe project
- Place the following code in form1
«code LangId=1»Private Declare Function BlockInput Lib "user32" (ByVal fBlock As Long)
....Read More |
Rating
|
|
|
How to disable form's Close button (X)?
|
Total Hit (4998) |
To modify an item in the Visual Basic Control menu (also known as the System menu), you need to use the SetMenuItemInfo API function. You can use ModifyMenuItem or EnablemenuItem api, both functions work. However it appears that Visual Basic re-enables the menu item whose ID is SC_CLOSE. This is why
....Read More |
Rating
|
|
|
|
|
|
|
|
|
|
|
GetFilebaseName - Retrieve the base portion in a file name
|
Total Hit (1581) |
«Code LangId=1»' Retrieve a file's base name
' if the second argument is true, the result include the file's path
Function GetFileBaseName(FileName As String, Optional ByVal IncludePath As _
Boolean) As String
Dim i As Long, startPos As Long, endPos As Long
startPos = 1
....Read More |
Rating
|
|
|
|
Reduce context overhead for COM+ components
|
Total Hit (1464) |
Instances of configured components, that is, components configured in COM+, get runtime services owing to context objects. When you instantiate a COM+ component, your instance will live in a context object. When you call a method of your instance, the call will go through the context and that is whe
....Read More |
Rating
|
|
|
Always run a component using Full-Compile
|
Total Hit (2723) |
When testing a component in the IDE, always perform a full compilation. This ensures that VB checks the syntax of all the code in the component, which in turn guarantees that no syntax error will break the program while it is serving another application.
You can activate the full compilation opti
....Read More |
Rating
|
|
|
How to apply the flat style to a toolbar
|
Total Hit (2652) |
All recent Windows applications use a flat toolbar similar to Internet Explorer 's and Microsoft Word's ones. Visual Basic 6 includes a Toolbar control that supports the flat look, but if you are still using VB4 or VB5 and you want to use a flat toolbar without buying a new ActiveX control, you just
....Read More |
Rating
|
|
|
Highlight the contents of a control on entry
|
Total Hit (1791) |
Here's a simple way to highlight the current word in a TextBox control (i.e. the word where the caret is):
«Code LangId=1»
Text1.SetFocus
SendKeys "^{LEFT}+^{RIGHT}"
«/Code»
Similarly, you can highlight the current line in a multiline TextBox control as follows: «Code LangId=1»
Text1.SetFo
....Read More |
Rating
|
|
|
Avoid beeps on forms without a default button
|
Total Hit (3928) |
If a form contains one CommandButton control whose Default property is set to True, the Enter key activates the CommandButton. If the form doesn't contain any default CommandButton control, however, pressing the Enter key when the focus is inside a TextBox control (and a few other controls as well)
....Read More |
Rating
|
|
|
Extract words with the RegExp object
|
Total Hit (3731) |
The following routine extracts all the words from a source string and returns a collection. Optionally, the result contains only unique words.
This code is remarkably simpler than an equivalent "pure" VB solution because it takes advantage of the RegExp object in the Microsoft VBScript Regular Expr
....Read More |
Rating
|
|
|
Replace the last occurrence of a string
|
Total Hit (3139) |
Here is a one-liner that replaces the last occurrence of a substring in a string. It is slightly less efficient than using the InstrRev plus a Replace statement, but at least you can use it in-line inside another expression. And it is also one of the few occasions to use the StrReverse function, und
....Read More |
Rating
|
|
|
|
Colour Depth Control
|
Total Hit (624) |
In VB, you cannot change the colour depth of a bitmap. This article presents classes allowing you to reduce or increase the colour depth using a number of different methods and also to save the resulting image to disk as a bitmap with the specified colour depth.
....Read More |
Rating
|
|
|
MS Money UI Style Sample
|
Total Hit (1351) |
This sample demonstrates using the vbAccelerator CommandBar control to create an MS Money style UI. The CommandBar control is used to provide an MS Money style menu, toolbar and status bar, as well as providing dynamic colourisation for other images used in the UI.
....Read More |
Rating
|
|
|
PopupMenu - Transparent Menu Demonstration
|
Total Hit (2516) |
All Windows controls provide a facility to show context menus when the user right clicks on the control through the WM_CONTEXTMENU message. VB doesn't provide a way to interact with this message however, so if you want to replace the default context menu on a TextBox, or to provide a custom context
....Read More |
Rating
|
|
|
Getting the Correct Filename for a Shortcut
|
Total Hit (2324) |
If your application creates or otherwise manipulates shortcuts then you should use the Operating System to determine what the filename for the shortcut should be, as the extension is subject to i18n. This article demonstrates how to use the SHGetNewLinkInfo API call to do this, and also provides a h
....Read More |
Rating
|
|
|
Using GetDiskFreeSpaceEx on 32-bit Windows
|
Total Hit (1325) |
This page presents four key wrapper routines for the data returned by the GetDiskFreeSpaceEx API. It works on both Win95 and Win95 OSR2, as well as Win98, NT4 Windows 2000 and Windows XP. By checking for the proc address of the GetDiskFreeSpaceExA API in kernel32.dll, which will only return a valid
....Read More |
Rating
|
|
|
Browsing in Win32/NT4 - An Overview
|
Total Hit (1579) |
Details on the ITEMIDLIST, SHITEMID, BROWSEINFO structures, and the SHGetSpecialFolderLocation, SHGetPathFromIDList and SHBrowseForFolder APIs.
|
Rating
|
|
|
Populating a Font Menu and Splitting a Long Menu into Columns
|
Total Hit (1300) |
In attempting to display a font selection menu on a system with many installed fonts, the menu, due to the number of installed fonts, often exceeds the screen height truncating the font list. This page is an extension of the code in How to Split a Long Menu into Columns. Here, we'll use the EnumFont
....Read More |
Rating
|
|