The Latest

DevX

Use enum Types in switch Statements

Certain compiler and code analyzers can detect a missing enumerator in a switch statement. Consider: enum Seasons{ Winter, Spring, Summer, Fall};switch (s){case Winter: wearCoat(); break;case Spring: pruneGarden(); break;case Summer: goSwimming();

DevX

Concatenating Variables

If you need to concatenate variables of different types to form a string, use a stringstream object. The header contains the declarations of the stringstream family of classes. Using its

DevX

Reading a String from the Standard Input

There are two methods of reading a string from the standard input. The first one uses getline(), as in the following example: std::string name;getline(cin, name); // option #1 The second

DevX

Setting a New Handler

The function std::set_new_handler() installs a function to be called when the global operator new or the global operator new[] fail. By default, operator new throws an exception of type std::bad_alloc

DevX

Floating Point Types

C++ defines three floating points datatypes: float, double and long double. Some existing implementations support only two (and in some cases only one) of these three. On such implementations, double

DevX

Generate a Relative Path Between Folders

You can use a Shell Light Weight API to generate a relative path by using this code: Private Declare Function PathRelativePathToW _Lib “shlwapi.dll” (ByVal pszPath As Long, _ByVal pszFrom As

DevX

Return the Fractional Part of a Number

No native VB function returns a fractional part of a decimal number. However, by subtracting the whole portion, obtained with Fix, from the original value, you can derive the fractional

DevX

Iterate Control Arrays Without Error

Control arrays are odd beasts in that they can have missing elements. The simplest way to iterate a control array uses this method: Dim i As IntegerFor i = Text1.LBound

DevX

Arrays With Non-Zero Lower Bounds

In VB.NET, you can use the System.Array class to create an array with non-zero lower bounds. To do this, use the System.Array.CreateInstance method: Array.CreateInstance(Type, Lengths(), LowerBounds( ) ).If the array

DevX

Instantiate an Object Inline

In VB.NET, you can instantiate a new instance of an object inline, making your code more compact. This example shows both versions: Imports SystemPublic Class Author Private fName As String

DevX

Storing Your Data in Oracle

hat block size did you choose for your database? How many chunks have been allocated for your table? How large is each chunk and what will the size of the

DevX

Lessons Learned in Enterprise Design and VB6

t’s now been more thantwo years since I wrote the article “18 CommonProgramming Traps in MTS.” The article wasgreat fun to write, and I received, and in fact am still

DevX

Providing a default value for optional arguments

Unlike VB6, VB.NET requires that you specify the default value of any Optional argument. In general you should use a value that is invalid under normal circumstances, so that the

DevX

Leverage the improved Shell function

The version of the Shell function included in VB.NET expands on the original version and supports an additional argument that enables you to specify whether to wait until the shelled

DevX

Exception debugging in Visual Studio .NET

The Visual Studio debugger offers complete control on what happens when an application throws an exception, or calls a .NET method that throws an exception. You set all the relevant

DevX

Use a ParamArray as a true array

Unlike VB6, in VB.NET the ParamArray keyword defines a true array object, which you can process using any of the methods of the Array class. For example, here’ s a

DevX

Licensed to Code?

Certifiable NonsenseYou don’t need a certification to know that you’re good at what you do and neither does the rest of &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbspthe world. I once had the misfortune to make

DevX

Use ASP Include Files for Database Connectivity

To avoid repeating the following lines of code in every ASP page that needs a database connection: {Dim connObjSet connObj = Server.CreateObject(“ADODB.Connection”)connObj.ConnectionString = Session(“ConnectionString”)connObj.Open} You can use an include file,

DevX

How to Void a Cookie and Delete it from the Browser

You can specify an expiration date, using the setMaxTime(int) method of javax.servlet.http.Cookie. Specifying an expiration time of zero will void the cookie, and delete it from the browser. // Expire

DevX

IIF Command in SQL Server

There is no “IIF” function in SQLSERVER as of VB and Access.For example, say you had a table like this: StudID Subject Marks—— —— ——1 Maths 801 Physics 751 Chemistry

DevX

Use ASP in your .js, .vb, and .css Files

Open Internet Services Manager from the Administrative Tools group.Right-click on your server and select properties. From Master Properties choose WWW Services and click the “Edit…” button. Select the HomeDirectory, and

DevX

String Comparing

Suppose that you have the following code: String strObj; if(strObj != null) if(strObj.equals(“something”)){ // } You can use instead “something”.equals(strObj), so you don’t have to test if strObj is null.