|
Language features - Operators
|
Total Hit (1978) |
In this article we will see all operators supported by VB.net
Here is the list of operators categories
«code LangId=999»<table class="dtTABLE" cellSpacing="0" id="table2" bordercolorlight="#808080" border="1" style="border-collapse: collapse" width="100%">
<tr vAlign="top">
<th wi
....Read More |
Rating
|
|
|
How to find all base classes of any type in .Net
|
Total Hit (2939) |
The following code shows how to print all base classes for a specified object.
«code LangId=2»Function PrintBaseClasses(ByVal obj As Object)
Dim t As System.Type
t = obj.GetType
Do While Not t Is Nothing
Debug.Write(t.Name)
t = t.BaseType
If Not t Is No
....Read More |
Rating
|
|
|
Measuring a string drawn with a specific font
|
Total Hit (2633) |
When you're dynamically drawing text (either on a Windows Form or Web Form application), you may need to calculate the width and height of a string printed with a particular font. This is easy with the Graphics class's Measure string method, that takes in input the string being measured, and the fon
....Read More |
Rating
|
|
|
|
ConcatenateStrings - Concatenating an array of strings
|
Total Hit (2720) |
«Code LangId=2»' Concatenate the input strings, and return the resulting string. The first
' input string is used as a separator.
'
' Example:
' Dim i As Integer = 4
' Dim d As Double = 34.45
' Dim s As String = "VB-2-The-Max"
' Dim ret As String = ConcatenateStrings(" ", s, "is a n
....Read More |
Rating
|
|
|
Sending a File to a Web Server
|
Total Hit (2930) |
«B»Description«/B»
This is a working example of sending a file to a web server, and then processing the file from memory without saving it to a file.
«B»ASP Page Code«/B»
You will need to create a new Web Form and add this ASP.NET code to it.
«Code LangId=2»
<%@ Page Language="vb" Au
....Read More |
Rating
|
|
|
Retrieving the state of the Shift, Alt and Ctrl keys, at any time
|
Total Hit (2528) |
You can know the state of the Shift, Alt and Control keys at any time, not just from inside a Keyxxx event. The shared property Control.ModifierKeys returns a bit coded value that identifies which of those keys are pressed, and you can use the And bit operator if a specific key is pressed. The follo
....Read More |
Rating
|
|
|
|
Add exception tracing with one line of code
|
Total Hit (3839) |
At times you want to keep a log of all the exception occurred in your application, including those that are correctly caught by a Catch block. At first you might believe that you need to add a call to the LogException procedure from each and every Catch block, which is clearly a nuisance:
«Code L
....Read More |
Rating
|
|
|
|
InstrTbl - Search a string for any character in a table
|
Total Hit (3585) |
«Code LangId=2»
' If INCLUDE is True or is omitted, return the first occurrence of a character
' in a group
' or -1 if SOURCE doesn't contain any character among those listed in TABLE.
' If INCLUDE is False, return the first occurrence of the character in SOURCE
' that does not appear in TABL
....Read More |
Rating
|
|
|
StripControlChars - Delete control characters in a string
|
Total Hit (4283) |
«Code LangId=2»
' Strip all control characters (ASCII code < 32)
'
' If the second argument is True or omitted,
' CR-LF pairs are preserved
Function StripControlChars(ByVal source As String, Optional ByVal KeepCRLF As _
Boolean = True) As String
' we use this to build the result
....Read More |
Rating
|
|
|
Reading text files
|
Total Hit (3888) |
In Visual Basic .NET you read a text file by first opening a StreamReader on it, and then iterating over all its lines until its Peek method returns -1:
«Code LangId=2»
Dim sr As New StreamReader("c:\autoexec.bat")
' Display all the text lines in the file.
Do Until sr.Peek = -1
' The Re
....Read More |
Rating
|
|
|
|
Caveats of the CopyMemory API function
|
Total Hit (4114) |
Here's the correct declaration of the CopyMemory API function, which is so useful whenever you want to move a block of bytes between two memory locations:
«Code LangId=2»
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (dest As Any, _
source As Any, ByVal bytes As Long)
«/Code
....Read More |
Rating
|
|
|
|
How Do I...Write to an event log?
|
Total Hit (2399) |
Event logging provides a standard, centralized way for your applications to record important software and hardware events. Windows supplies a standard user interface for viewing the logs (the Event Viewer). Using the common language runtime's EventLog component, you can easily connect to existing ev
....Read More |
Rating
|
|
|
How Remoting Works
|
Total Hit (1531) |
The .NET Remoting framework provides developers with a modern distributed object model that allows remote method invocation between different common language runtimes across the network or between different AppDomains in the same common language runtime. Any interaction with a remote object occurs t
....Read More |
Rating
|
|
|
How Do I...Use an XPathExpression class?
|
Total Hit (1052) |
This sample illustrates how to use an XPathExpression class to compile an XML Path Language (XPath) expression to select a node-set from an XML file. Then the sample demonstrates how to add a custom sort routine and use an XPathExpression to sort the elements returned by the compiled XPath. Finally,
....Read More |
Rating
|
|
|
.NET Button ListBar Control
|
Total Hit (2250) |
The Button ListBar control provides an emulation of the ListBar provided in the Windows Add/Remove Programs window. Under XP it uses the UxTheme API to draw parts of the toolbar, and degrades to use standard GDI drawing calls when used on earlier OS versions. Both C# and VB.NET versions of the same
....Read More |
Rating
|
|
|
|
Subclassed System Menu
|
Total Hit (2125) |
The reason for this article is to show a method of subclassing an application's system menu, so that extra menu items can be added and click events can be easily handled. This is my first article submitted to CodeProject and all suggestions, criticisms etc. are welcome.
....Read More |
Rating
|
|
|
|
|
Stopwatch - a High-Resolution code timer class
|
Total Hit (2193) |
Creating an application requires precisely measuring how long specific operations take to complete. You may be searching for performance bottlenecks prior to shipping, measuring to ensure that changes do not unexpectedly degrade performance, or (in my case), testing alternative architectural approac
....Read More |
Rating
|
|
|
|
|
How Do I...Handle Events from XmlDocument?
|
Total Hit (913) |
This sample illustrates how to receive and handle events when nodes in an XML document change. In particular, this sample demonstrates how to catch the NodeChanged and NodeInserted events described in the following paragraphs.
Modifying an XmlDocument can result in one or more of the following e
....Read More |
Rating
|
|
|
|
How Do I...Enumerate directories and their contents?
|
Total Hit (1273) |
This sample illustrates how to use the DirectoryInfo class to create a directory listing. This is a great way to quickly list files for users or reports, or to find basic information about a specific directory. When used in combination with FileInfo, you can get all the information you need about fi
....Read More |
Rating
|
|