Rules at a Glance Qtt

The following intrinsic conversion constants specify the type of conversion to perform The first letter of every word in str to an uppercase character. Narrow single-byte characters in str to wide doublebyte characters. Wide double-byte characters in str to narrow singlebyte characters. Hiragana characters in str to Katakana characters. Katakana characters in str to Hiragana characters. Uses linguistic rules for casing. Can be used only with Traditional Chinese characters in str to Simplified...

Description Cnx

The Directory class represents a directory or folder. It appears that Microsoft is retreating from the term folder, in favor of the legacy term directory. The Directory class has a number of methods that allow you to retrieve information about the directory's system properties, to move and delete a directory, and to create a new directory. Unfortunately, however, the Directory class lacks a Copy method. All of the members of the Directory class are shared methods, so they can be called without...

Rules at a Glance Flk

To use the Err.Raise method, you must specify an error number. If you supply any of the number, source, description, helpfile, and helpcontext arguments when you call the Err.Raise method, they are supplied as values to the Number, Source, Description, HelpFile, and HelpContext properties, respectively. Refer to the entries for the individual properties for full descriptions of and rules for each property. The number argument is a Long integer that identifies the nature of the error. Visual...

Programming Tips and Gotchas Mjd

The RGB value is actually derived using the following formula RGB red green 256 blue 65536 In other words, the individual color components are stored in the opposite order than you would expect. VB stores the red color component in the low-order byte of the integer's low-order word, the green color in the high-order byte of the low-order word, and the blue color in the low-order byte of the high-order word. Visual Basic now contains a wide range of intrinsic color constants that can be used to...

Example Gpw

sOldName InputBox Enter the file name to rename sNewName InputBox Enter the new file name Rename c amp sOldName, c amp sNewName Catch ex As Exception MsgBox Err.GetException .ToString Exit Sub End Try End Sub If the user inputs an invalid filename in the first input box, the result is the following message that displays information about the error System.IO.FileNotFoundException File not found at OldPath, String NewPath at WindowsApplication2.Form1.RenameFile in C Documents and Settings sr My...

Programming Tips and Gotchas Nxt

The LastDLLError property can be changed by VB at any time, so it is important to save the value in an independent variable as soon as possible. The LastDLLError property is only used by system DLLs, such as kernel32.dll. Therefore, errors that occur within DLLs you may have created will not cause an error code to be assigned to the property. Obtaining accurate documentation about the return values of system DLLs can be a challenging experience Most useful information can be found by studying...

Syntax Meb

AccessModifier Delegate Sub name arglist AccessModifier Delegate Function name arglist As type AccessModifier Specifies scope accessibility the same as when declaring a subroutine or function. Can be one of Public,Private,Protected,Friend, Protected Friend, or Shadows. The argument list it has the same syntax as when defining a subroutine or function.

Rules at a Glance Oxi

Although both pathname and class are optional, at least one parameter must be supplied. In situations where you cannot create a project-level reference to an ActiveX object, you can use the GetObject function to assign an object reference from an external ActiveX object to an object variable. GetObject is used when there is a current instance of the ActiveX object to create the instance, use the CreateObject function. If you specify pathname as a zero-length string, GetObject will return a new...

Example Amf

This example uses both InStr and InStrRev to highlight the different results produced by each. Using a stringcheck of I like the functionality that InStrRev gives, InStr finds the first occurrence of th at character 8, while InStrRev finds the first occurrence of th at character 26. myString I like the functionality that InsStrRev gives sSearch th Debug.WriteLine InStr myString, sSearch Debug.WriteLine InStrRev myString, sSearch

Programming Tips and Gotchas Qpa

Your code may be more readable if you take advantage of the fact that VB allows lengthy constant and variable names. This allows you to choose these names in a more meaningful way. If you are building a large application with many different modules, you may find your code easier to maintain if you create a single separate code module to hold your Public constants. If two or more constants are related, you should define them as members of an enumeration using the Enum statement.

Eqv and Imp

Eqv and Imp, two logical and bitwise operators, present in VB 6, have been removed from VB .NET. Eqv can simply be replaced with the comparison operator. Hence, the expression Imp can be replaced with an expression using the Not and Or operators. For example For example, the result of 15 Xor 179 is 188, as the following binary representation shows

Error Constants

To raise our own errors using the Err.Raise method, we need error numbers that do not conflict with those used by Visual Basic. The Visual Basic documentation says that error numbers in the range vbObjectError to vbObjectError 65535, where vbObjectError is a built-in constant whose value is the signed integer -2147220991 or amp H8004000 as an unsigned hexadecimal integer , are designed to signal an error generated by an object. It further says that error numbers below vbObjectError 512 may...

Object data type

The Object data type is a pointer data type. That is, a value of type Object is an address that references the object in memory. In VB .NET, the Object data type is the universal data type an Object variable can refer to point to data of any other data type. For instance, the following code places a Long value in an Object variable The underlying .NET data type for Object is System.Object. It is worth noting that when we use variables of type Object, we do pay a performance penalty because VB...

Syntax Qmc

DateAdd interval, number, datevalue interval Data Type String or DateInterval enum A String expression see the first item in Rules at a Glance or a member of the DateInterval enumeration see the second item in Rules at a Glance that specifies the interval of time to add. An expression denoting the number of time intervals you want to add it can be positive or negative Data Type Date, or an expression capable of conversion to a date Date representing the starting date to which the interval is to...

Finalize Dispose and Garbage Collection

In VB 6, a programmer can implement the Class_Terminate event to perform any clean up procedures before an object is destroyed. For instance, if an object held a reference to an open file, it might be important to close the file before destroying the object itself. In VB .NET, the Terminate event no longer exists, and things are handled quite differently. To understand the issues involved, we must first discuss garbage collection. When the garbage collector determines that an object is no...