October 25, 2001

LTrim(),RTrim(),Trim() Functions in JavaScript

JavaScript lacks the Trim() function. See below the code for trimming a string: function LTrim(ValueToTrim){ValueToTrim =ValueToTrim.toString()var WhiteSpace=new String(” “);var i=0;while(WhiteSpace.indexOf(ValueToTrim.charAt(i))>-1){ i++;}return ValueToTrim.substring(i);}function RTrim(ValueToTrim){ ValueToTrim =ValueToTrim.toString() var WhiteSpace=new String(” “); var i=ValueToTrim.length-1; while(WhiteSpace.indexOf(ValueToTrim.charAt(i))>-1){ i–;}return ValueToTrim.substring(0,i+1);}function Trim(ValueToTrim){ return LTrim(RTrim(ValueToTrim))} LTrim – Trims of Whitespace at beginning of the string.RTrim – Trims of

How to Determine User Access Rights for a Windows NT Authenticated Web Site

First, you have to disable the Anonymous access for the site and activate Window/Basic Authentication. You can get information about a logged on User with: Loggedonuser=Request.ServerVariables(“Auth_User”) You can get the proper path of the user with: strUserId = Ucase(Loggedonuser)strUserId = Split(Loggedonuser,””)strUserId = domainName & “/” & strUserIdstrPath = “WinNT://” &

Advanced Sorting Using the CASE Statement

Many developers use the CASE statement in the select list of a SQL statement. But not everybody knows that it can be used to do so much more. One example is to use it for advanced sorting.For example, say that you want to create a guest list for a customer

Avoiding Trouble with Lower Compatibility Modes

If you have a database that’s been upgraded from SQL Server 6.5 to a newer version (like 7 or 2000), but it’s still in compatibility mode 65, you can’t use keywords that don’t exist in this compatibility mode. One example of such a keyword is TOP. Look at the following

Enforcing a Class Object to Be Allocated on the Free Store

Sometimes you need to enforce objects of a certain type to be allocated only on the free store (heap) rather than on the stack.That’s if you need somewhere to call a delete on a pointer. If the pointer points to something on the stack and you try to delete it,

Unicode and the Watch Debugger Window

Managing Unicode strings (LPWSTR, BSTRs, etc.) is now a very common task. However, Visual Studio 6 does not allow you to view Unicode strings correctly in the watch window. It simply displays the first character, believing that the variable points to an ANSI string.To enable Unicode string debugging, get into

Security101: MessageDigest Class

In Java, message digest is represented by “java.security.MessageDigest class”.All main classes in java.security package are instantiated using the factory method “getInstance()”.This method takes the String parameter, which is the name of the algorithm used to calculate message digest. There are three algorithms supported by the default JDK security provider: “SHA”

Security101: MessageDigest

Message digest is a hash code of a byte sequence (message).It has certain properties that make it very unique and very useful: It has a fixed size (in bytes), which does not depend on the size of the original byte sequence. It is always the same for the same byte

How to Use the QuickSort Algorithm to Sort MS Flex Grid

Using this code will rewrite all the rows in MS Flex Grid and it supports alphanumeric as well as numeric sorts for specified columns.Good Luck! Option ExplicitPublic Sub QSort(Grid As MSFlexGrid, ByVal Column As Integer, ByVal min AsLong, _ ByVal max As Long, ByVal Ascending As Boolean, ByVal NumComp As

No more posts to show