|
|
|
ChangeFileExtension - Modify the extension in a file name
|
Total Hit (2704) |
«Code LangId=1»
' Change the extension of a file name
' if the last argument is True, it adds the extension even if the file doesn't
' have one
Function ChangeFileExtension(FileName As String, Extension As String, _
Optional AddIfMissing As Boolean) As String
Dim i As Long
For
....Read More |
Rating
|
|
|
|
IsNullString - Check whether a string contains white-spaces
|
Total Hit (1966) |
«Code LangId=1»
' Return True is a string is made only of spaces, tabs, and Null characters.
' This function is especially useful to test whether fixed-length strings
' are initialized.
Function IsNullString(Text As String) As Boolean
Dim i As Long
For i = 1 To Len(Text)
Se
....Read More |
Rating
|
|
|
|
InstrWord - Search a whole word
|
Total Hit (1558) |
«Code LangId=1»' Return the next occurrence of a whole word
Function InstrWord(start, Text, search, compareMethod) As Long
Dim index As Long
Dim charcode As Integer
' assume the search fails
InstrWord = 0
index = start - 1
Do
' search the next
....Read More |
Rating
|
|
|
Fract - The fractional portion of a number
|
Total Hit (1533) |
«Code LangId=1»' The fractional part of a floating-point number
' note that negative numbers return negative values
Function Fract(number As Variant) As Variant
Fract = number - Fix(number)
End Function
«/Code»
|
Rating
|
|
|
Display the dialog to configure a port
|
Total Hit (2896) |
The ConfigurePort API function lets you programmatically bring up the system dialog box for configuring a COM or LPT port. The function returns a non-zero value if successful (that is, the dialog appears). Here is the Declare of this function, and an example of its usage:
«Code LangId=1»
Privat
....Read More |
Rating
|
|
|
Undocumented dialog box to change screen saver's password
|
Total Hit (2008) |
When you write a screen saver in C and SDK you can use a static library (SCRNSAVE.LIB) that allows you to create custom dialogs to change and request the password. In VB you can't access this library, but if you don't want to create your forms to replace the custom dialogs, you can use a couple of u
....Read More |
Rating
|
|
|
Retrieving Bitmap properties
|
Total Hit (4072) |
The Picture box control does not directly expose any property that returns information on the bitmap currently loaded. You can retrieve this information by calling the GetObject API function, passing it the handle of the bitmap. This value is the Handle property of the IPictureDisp object (which is
....Read More |
Rating
|
|
|
Create ListBox controls with companion priority buttons
|
Total Hit (2782) |
You can easily create a ListBox control similar to the one found in the VB's Project References dialog box, that lets you select multiple items and move them up and down using two companion buttons.
First of all, create a ListBox control (say, List1) and two CommandButton controls to its right, n
....Read More |
Rating
|
|
|
Change the DataSource at runtime
|
Total Hit (3723) |
Visual Basic 6 is the first VB version that lets you programmatically change the DataSource property at runtime, for example to point to another ADO Data control or another ADO Recordset.
However, when you assign the new DataSource property VB immediately checks that the DataField and DataMember
....Read More |
Rating
|
|
|
Add comments to End If and Loop statements
|
Total Hit (2378) |
Here's a little programming tip that will save you hours of headaches later.
Most of us already indent our Ifs, Selects, Do...Loops, etc., and that is good. But suppose you have some fairly complex code with several levels of indentation. Example:
«Code LangId=1»
If A= 0 and B=1 then
'
....Read More |
Rating
|
|
|
Scan all the items in a multi-dimensional array with only one loop
|
Total Hit (2401) |
It seems that you need two nested For loops to iterate over all the elements of a 2-dimensional array, and three loops for a 3-dimensional array, and so on. However, the For Each loop offers you a neat and concise solution, as this code proves:
«Code LangId=1»
' a 2-dimensional array of Strings
....Read More |
Rating
|
|
|
Count distinct characters in a string
|
Total Hit (3790) |
When you need to count how many occurrences of a given character are in a string, you might be tempted to go along the "traditional" Visual Basic way:
«Code LangId=1»
' count spaces
For i = 1 To Len(text)
If Mid$(text, i, 1) = " " Then count = count + 1
Next
«/Code»
Ev
....Read More |
Rating
|
|
|
|
clsEMF : A class to Create/Play/Save Enhanced Meta File (EMF).
|
Total Hit (6187) |
Internally, a metafile is an array of variable-length structures called metafile records. The first records in the metafile specify general information such as the resolution of the device on which the picture was created, the dimensions of the picture, and so on. The remaining records, which consti
....Read More |
Rating
|
|
|
Enumerating all available Clipboard formats
|
Total Hit (7772) |
Sometimes in your application you might want to check if any Clipboard data available and if available then in which format. You can check format of clipboard data and you can enable/disable menu options based on available clipboard data formats. For example in timer event you can check for CF_BITMA
....Read More |
Rating
|
|
|
|
Get IP from Host Name.
|
Total Hit (3961) |
This example will show you how to get IP address from host name and also How to retrive all associated IPs to your local machine.
|
Rating
|
|
|
How to open a file with Wordpad or Notepad
|
Total Hit (2895) |
I tried to find sourcecode which allows me to open a file with any extension with Wordpad and Notepad. And finally I came up with this solution.
Happy Programming....
|
Rating
|
|
|
|
|
How to Toggle a Checkbox in a ListView
|
Total Hit (704) |
The routines here set and retrieve checked ListItems from a ListView control in report view.
Basically, here we are again using the enhanced comctl32.dll functionality, this time using the LVIS_STATEIMAGEMASK and LVIF_STATE to toggle the bits at &H1000 and &H2000. In addition, by using the messag
....Read More |
Rating
|
|
|
ListView Demo 3 - Adding Sorting Functionality
|
Total Hit (979) |
This page adds a popup menu and the routines necessary to sort and change list views.
When the demo is completed, the final app will retrieve the users selection and populate the listview with selected files from that folder, complete with associated icons, file name, file type, file size and cre
....Read More |
Rating
|
|
|
Changing the Combo Dropdown Height
|
Total Hit (656) |
The Visual Basic combo box dropdown - unlike its C counterpart - is limited to displaying only eight items. This page shows how to change the dropdown height to any number greater than eight.
|
Rating
|
|
|
|
Get an RGB Colour from an OLE_COLOR
|
Total Hit (1521) |
Sometimes you need to know the Red, Green and Blue values of a Visual Basic/COM OLE_COLOR, particularly if you are going to use the colour in an API function. This tip shows you how to correctly convert an OLE_COLOR type to a RGB value using the OleTranslateColor API call exposed by OLEPRO32.DLL. It
....Read More |
Rating
|
|
|
Reading and Writing JPG, PNG, TIF and GIF Files
|
Total Hit (832) |
This article demonstrates using GDI+ to read and write files in multiple formats (JPEG, PNG, TIF, GIF and BMP files are all supported for reading and writing; you can also read EMG, WMF and ICO files).
Using GDI+ is a great alternative to using the Intel JPEG Library that is now no longer distri
....Read More |
Rating
|
|