|
Any2Dec - Convert from any numeric base to decimal
|
Total Hit (2899) |
«Code LangId=2»' convert from any base to decimal
' BASE can be in the range 2-36
Function Any2Dec(ByVal otherBaseNumber As String, ByVal base As Integer) As Long
Dim digits As String
Dim digitValue As Long
' check base
If base < 2 Or base > 36 Then
Throw New Argum
....Read More |
Rating
|
|
|
A better way to query for a single node
|
Total Hit (2519) |
In the XmlNode class, that is the class that provides node functionality in an XMLDOM representation of an XML document, the SelectNodes (and the ancillary SelectSingleNode) method exploits the XPath query language to let you extract nodes based on logical conditions. The SelectNodes methods return
....Read More |
Rating
|
|
|
Handle child XML nodes with care
|
Total Hit (2641) |
When you work with XML documents loaded into an XmlDocument class, you often need to examine the contents of child nodes. The XMLDOM programming interface purposedly provides the ChildNodes property. In the .NET XmlDocument class, ChildNodes returns an internal object of type XmlChildNodes. (The obj
....Read More |
Rating
|
|
|
Ask a Yes/no question and return a Boolean
|
Total Hit (2833) |
«Code LangId=2»
' Ask a Yes/no question
' returns True if the user replies "Yes"
' Example: MessageBox.Show(AskYesOrNo("Do you like me?", "ME", True))
Function AskYesOrNo(ByVal text As String, ByVal title As String, _
ByVal defaultAnswer As Boolean) As Boolean
Dim defButton As Messa
....Read More |
Rating
|
|
|
CompareList - Compare an argument with a list of values
|
Total Hit (2566) |
«Code LangId=2»' Return the position of the argument in a list of values
' or zero if the argument isn't included in the list
' It works for both regular values and for objects
'
' This handy function can often save you a lengthy Select Case
' statement or a complex series of If...ElseIf block
....Read More |
Rating
|
|
|
CompareValue - Check whether a value is in a list of values
|
Total Hit (2708) |
«Code LangId=2»' Compares a numeric or string value with a list of other values.
' Returns the 1-based index of the matching value, or zero if the
' value doesn't appear in the list.
' String comparisons are case-sensitive.
'
' This function can conveniently replace a Select Case or a list
'
....Read More |
Rating
|
|
|
DisplayExceptionInfo - Displaying error information
|
Total Hit (2796) |
«Code LangId=2»
' A reusable routine that displays error information
' Note: requires Imports System.Reflection
Sub DisplayExceptionInfo(ByVal e As Exception)
' Display the error message.
Console.WriteLine(e.Message)
Dim st As New StackTrace(e, True)
Dim i As Integer
....Read More |
Rating
|
|
|
|
|
|
IsComDLL - Check whether a DLL is an COM self-registering server
|
Total Hit (3048) |
«Code LangId=2»<System.Runtime.InteropServices.DllImport("kernel32")> Shared Function _
LoadLibrary(ByVal path As String) As Integer
End Function
<System.Runtime.InteropServices.DllImport("kernel32")> Shared Function _
GetProcAddress(ByVal hModule As Integer, ByVal procName As String)
....Read More |
Rating
|
|
|
|
IsValidEmail - Validate an email address
|
Total Hit (2637) |
«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
|
|
|
|
IsValidUsPhoneNumber - Validating a US phone number
|
Total Hit (2996) |
«Code LangId=2»
' Validate a US phone number
' Example:
' MessageBox.Show(IsValidUsPhoneNumber("(123) 456-7890")) ' True
' MessageBox.Show(IsValidUsPhoneNumber("(123) 456-78901")) ' False
Function IsValidUsPhoneNumber(ByVal phnNum As String) As Boolean
Return System.Text.RegularExp
....Read More |
Rating
|
|
|
IsValidEmail - Validate an email address
|
Total Hit (3429) |
«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
|
|
|
IsValidUsPhoneNumber - Validating a US phone number
|
Total Hit (2959) |
«Code LangId=2»
' Validate a US phone number
' Example:
' MessageBox.Show(IsValidUsPhoneNumber("(123) 456-7890")) ' True
' MessageBox.Show(IsValidUsPhoneNumber("(123) 456-78901")) ' False
Function IsValidUsPhoneNumber(ByVal phnNum As String) As Boolean
Return System.Text.RegularExp
....Read More |
Rating
|
|
|
IsValidUsSSN - Validating a US Social Security Number (SSN)
|
Total Hit (3934) |
«Code LangId=2»
' Validate a US Social Security Number
' Example:
' MessageBox.Show(IsValidUsSSN("123-12-1234")) ' True
' MessageBox.Show(IsValidUsSSN("123-123-1234")) ' False
Function IsValidUsSSN(ByVal ssn As String) As Boolean
Return System.Text.RegularExpressions.Regex.IsMatch(
....Read More |
Rating
|
|
|
IsValidUsZip - Validating a US ZIP code
|
Total Hit (2797) |
«Code LangId=2»
' Validate a US ZIP code
' Example:
' MessageBox.Show(IsValidUsZip("12345")) ' => True
' MessageBox.Show(IsValidUsZip("12345-1234")) ' => True
' MessageBox.Show(IsValidUsZip("12345-12345")) ' => False
Function IsValidUsZip(ByVal zip As String) As Boolean
Re
....Read More |
Rating
|
|
|
KeepInRange - Ensure that a value is in a given range
|
Total Hit (2550) |
«Code LangId=2»
' Keep the first argument in the range [lowLimit, highLimit]
' If the value is adjusted, the fourth (optional) argument is set to True
'
' This function works will all basic data types and with objects
' that implement the IComparable interface
Function KeepInRange(ByVal va
....Read More |
Rating
|
|
|
|
|
Calling web services from behind a proxy server
|
Total Hit (2088) |
When you use a web service's proxy class, the calls to the web service might fail if you're behind a proxy server. To solve the problem, you set the Proxy property of a web service's proxy class to an instance of WebProxy, that contains the HTTP proxy settings needed for the web method calls. Here's
....Read More |
Rating
|
|
|
Make read-only properties visible to Web Services clients
|
Total Hit (2056) |
Read-only and write-only properties in a Web Service class aren't visible to the Web Service client. The reason is that XML serialization doesn't support these sort of properties, and read-only and write-only properties aren't included in the Web Services Description Language (WSDL) documentation.
....Read More |
Rating
|
|
|
Disable .NET security
|
Total Hit (2048) |
The .NET Framework enforces secuity at several levels. For example, assemblies downloaded from the Internet have very limited permissions (especially after installing the Service Pack 1 of the Framework). This means that many operations that would be legal in some cases may throw an exception in oth
....Read More |
Rating
|
|
|
Reduce COM+ context overhead: activate in the caller's context
|
Total Hit (2690) |
Even though you may want to use some COM+ services, it doesn't mean that you have to have a unique context for each and every instance. The root instance, that is, the instance that the client uses, must have a context, but the secondary instances can often co-locate within the first context.
In
....Read More |
Rating
|
|
|
Reduce COM+ context overhead: use modules and shared members
|
Total Hit (2723) |
If you use Shared members in .NET or modules in VB6, you reduce COM+ context overhead without any risk whatsoever that you will get extra context overhead for that code. You also release yourself from the clean-up burden that you have in both worlds. Instead of the VB6 consumer code:
«Code LangId
....Read More |
Rating
|
|
|
|
Support COM+ constructor strings in serviced components
|
Total Hit (2803) |
Having a VB6 component support a COM+ construction string requires that you implement the IObjectConstruct interface and its only method, Construct. The .NET ServicedComponent class implements this interface internally and expose the Construct method as a protected, overridable method. Thus your VB.
....Read More |
Rating
|
|
|
Take advantage of COM+ object pooling
|
Total Hit (2667) |
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
|
|