June 4, 1999

Class Module(.cls) vs. Module(.bas)

Question: For the same global function, what’s the difference between placing it in a global module and in a class module?Are there any performance issues involved? If so, which way is recommended and better? Answer: Deciding between a standard module and a class module is not a decision based on

Rounding function

Question: Is there a way to round numbers to the nearest multiple of n, where n could be any number? For example, if n = 5, it would round 8 to 10, 13 to 10, 24 to 25, etc. Answer: There is no native function that I know about that

String Manipulation

Question: I have a VB app which formats a large text file and then prints it using MS Word. I need to include what amounts to a thick underscore in certain places in the margin (each page is unique). I am limited to using a non-proportional font (Courier or Letter

ActiveX EXE vs. DLL

Question: I have an ActiveX dll into which I can pass an existing ImageList containing a set of images. This works fine and means that I only have to maintain the code / images in one place.However, I have now written an ActiveX exe into which I also wish to

DataObject Object

Question: In an event, I declared a dataobjectvariable and instantiated it this way : Dim do_1 as dataobject Set do_1= New dataobject But when I run the program I get thiserror: “Invalid use of ‘new’ keyword”Why is this happening? Answer: The dataObject is a container to transfer data from a

Accessing a C++ Object in C Code: A Concrete Example

The C++ Standard guarantees that within every instance of class Date, data members are set down in the order of their declarations (static data members are stored outside the object and are therefore ignored). Consider this declaration of the class Date: class Date{public: int day; int month; int year; Date();

Implement a Confirm Box That Redirects Based on a User’s Choice

You can easily create a function that redirects to a different page depending on a user’s choice of OK or Cancel. You should use JavaScript’s confirm command and then based on what is returned change the location property of the window object appropriately.For example: Click here to go to a

Customizing Serialization

If a class contains non-serializable variables, and you need to preserve the state of those variables, you will have to customize the default serialization behavior of the class. You can achieve this by providing an implementation for the readObject() and writeObject() methods in the class. These implementations should manually serialize

Avoid Serialization Using the Transient Modifier

One of the less commonly used keywords in the Java language is transient. The transient modifier came into effect in JDK 1.1. It indicates a field that is not a part of the object’s persistent state. Hence, declaring a variable as transient prevents it from being serialized. If the NotSerializableObject

No more posts to show