|
Take advantage of COM+ object pooling
|
Total Hit (2659) |
VB6 objects can't be pooled under COM+, because they are apartment threaded. This restriction is void with VB.NET objects (and all .NET objects in general), because they are free-threaded. To make an object poolable you just need to decorate the class with the ObjectPooling attribute:
«Code LangI
....Read More |
Rating
|
|
|
|
|
|
|
|
SearchFileOnPath - Searching a file on the system
|
Total Hit (2695) |
«Code LangId=2»<System.Runtime.InteropServices.DllImport("kernel32")> Shared Function _
SearchPath(ByVal tartPath As String, ByVal fileName As String, _
ByVal extension As String, ByVal bufferLength As Integer, _
ByVal buffer As System.Text.StringBuilder, ByVal filePart As String) As
....Read More |
Rating
|
|
|
|
App.Path in VB.NET
|
Total Hit (3135) |
The APP Object no longer exists in VB.NET, so calling App.Path to get the location of your application does not work. Thankfully there are many other ways to do this in VB.NET, here are a few.
NOTE: Some of these will only work for forms and not DLL's without any UI. The first two that reference
....Read More |
Rating
|
|
|
|
|
Building arrays on the fly
|
Total Hit (2865) |
VB.NET supports the creation of arrays on-the-fly, by using the New operator. For example, look at the following code, that uses GDI methods to display few connected lines
«Code LangId=2»
' Get the Graphics object from the form.
Dim gr As Graphics = Me.CreateGraphics
' Draw three straight line
....Read More |
Rating
|
|
|
Write a console utility to kill a process
|
Total Hit (2922) |
The System.Diagnostics.Process class exposes two methods that let you kill a process: CloseMainWindow should be used with processes that have a graphical interface, whereas the Kill method should be used for apps without a user interface (or those whose main window is disable and can't process the W
....Read More |
Rating
|
|
|
BinToDec - Convert from binary to decimal
|
Total Hit (3670) |
«Code LangId=2»' convert from binary to decimal
Function BinToDec(ByVal value As String) As Long
' we just need a call to the Convert.ToInt64 static method
Return Convert.ToInt64(value, 2)
End Function
«/Code»
|
Rating
|
|
|
|
Set up event handlers through reflection
|
Total Hit (2520) |
Reflection makes it easy to invoke a method (or assign a field or a property) by its name. For example, suppose you have the following classes:
«Code LangId=2»
Class Person
Event PropertyChanged(ByVal propertyName As String, ByVal newValue As Object)
Dim m_Name As String
Property
....Read More |
Rating
|
|
|
|
How to assign ItemData to combobox / listbox in VB.net
|
Total Hit (9831) |
There is no ItemData property in VB.net for ComboBox and ListBox but you can use another approach which will give you same functionality of ItemData.
Use following code to test how you can assign ItemData. ItemData is generally used to store Id related to the Item of list.
....Read More |
Rating
|
|
|
IsValidEmail - Validate an email address
|
Total Hit (2627) |
«Code LangId=2»
Function IsValidEmail(ByVal Value As String, Optional ByVal MaxLength As _
Integer = 255, Optional ByVal IsRequired As Boolean = True) As Boolean
If Value Is Nothing OrElse Value.Length = 0 Then
' rule out the null string case
Return Not IsRequired
....Read More |
Rating
|
|
|
FolderHasFiles - Returns whether the specified folder has files
|
Total Hit (2678) |
«Code LangId=2»
' Returns a boolean indicating whether the specified folder has files
Function FolderHasFiles(ByVal folderPath As String) As Boolean
Return System.IO.Directory.GetFiles(folderPath).Length > 0
End Function
«/Code»
|
Rating
|
|
|
Retrieve Windows and System directories
|
Total Hit (3103) |
In VB.NET you don't need to call the GetWindowsDirectory and GetSystemDirectory API functions to retrieve the path the Windows and System directories. Retrieving the System directory is as simple as calling the Environment.SystemDirectory property:
«Code LangId=2»
Dim sysDir As String = Environm
....Read More |
Rating
|
|
|
|
ADO.NET: Populate a DataSet from a Database
|
Total Hit (587) |
Getting data from a database is easy, and working with data is easier than before. If you want the results from a database as a forward only, read-only stream of data, you can execute a command and retrieve the results using the DataReader. For examples on how to use a DataReader, see Retrieve Data
....Read More |
Rating
|
|
|
Monitoring File System Events
|
Total Hit (1268) |
In some applications like file system explorers, file managers etc. it becomes necessary to keep an eye on file system changes. In traditional tools like VB6 this task usually required some third party component or Windows APIs. In .NET the FileSystemWatcher class from System.IO namespace provides e
....Read More |
Rating
|
|
|
Controlling scrolling with the API
|
Total Hit (2544) |
In certain circumstances, we need to be able to control the scroll bars from our code. This may seem like it should be easily done with standard methods when in fact they are buried in the API. I will tell you how I solved this problem in the application I am working on.
....Read More |
Rating
|
|
|
How do I read/write objects into xml?
|
Total Hit (1036) |
This topic describes how to automatically map a particular XML stream into a set of objects designed to hold the XML using the XML Serialization classes.
|
Rating
|
|
|
|
Formatting with Regular Expressions
|
Total Hit (2844) |
If you're familiar with regular expressions, you know that they can be used for pattern matching and replacement in strings. (If you are not familiar with regular expressions, you're missing out on a powerful technology that has a myriad of applications. Read An Introduction to Regular Expressions t
....Read More |
Rating
|
|
|
How Do I...Count rate of change?
|
Total Hit (939) |
Windows performance counters enable your applications and components to publish, capture, and analyze the performance data that applications, services, and drivers provide. You can use this information to determine system bottlenecks and fine-tune system and application performance. For example, you
....Read More |
Rating
|
|
|
How To Recursively Search Directories by Using Visual Basic .NET
|
Total Hit (1556) |
This article demonstrates through code how to recursively search subdirectories for files, starting with a root directory. A search string is specified so that you can search for files that match a certain criteria. Each part of the code is explained as necessary. A working code sample is also provi
....Read More |
Rating
|
|