March 21, 2001

Deleting Files or FileTypes En Masse

Sometimes you run into a situtation where you want to delete all the files or a particular type of file (like text files – *.txt) in a folder.Here is a function to do just that: Private Sub DeleteFilesInFolder(ByVal strFolder As String, OptionalstrFileExt As String =

The Difference Between BSTR and Unicode Strings

Though each character of BSTR and Unicode strings are 2 characters wide, there is a fundamental difference between the two. BSTR strings have to be length prefixed, which means that the memory locations at the very beginning of the string contain the length of the string. BSTRs also have to

Restrict a Textbox to Accept Only Numbers

Sometimes we may need to restrict users from entering anything besides numbers in a textbox. The following code can achieve this: Option ExplicitPrivate strClipboardText As StringPrivate Sub txtNumberBox_KeyPress(KeyAscii As Integer) If (KeyAscii

Concatenating Big Strings

Please note that using the join function makes this code VB6 only (for only a small performance gain). dim i as longdim s as stringfor i = 0 to 100000 s = s &

Determine Whether a User Session Has Expired or Been Removed

Define a class, say SessionTimeoutIndicator, which implements theinterface javax.servlet.http.HttpSessionBindingListener. Next create a SessionTimeoutIndicator object and add it to the user session. When the session is removed, the SessionTimeoutIndicator.valueUnbound() method will be called by the Servlet engine. You can then implement valueUnbound() to do the required operation.

C++ Exceptions Will Not Cross COM Boundaries

When writing a COM object using C++, care should be taken to ensure that all C++ exceptions generated by the code are handled within the call itself. If any C++ exception is not handled, the call will fail.For example: CMyComObject::foo(){ HRESULT hr;… throw hr;}