Category Archive for: Optimizing VB Applications

Providing Feedback with a Progress Bar

Notice that the revised Image application uses aft additional Form with a Progress Bar control, which shows the progress of the. algorithm. The ProgressBar control’s value is set after each completion of the inner loop. which processes one line of pixels. Since the image on the PictureBox control isn’t updated in real time, the progress bar provides some feedback…

Read More →

Optimizing the Image application

The unage application presented in Chapter 7 processes images by manipulating each and every pixel of the image individually. This application easily performs a few million operations for a small image, so it’s no surprise that it’s slow. For instance, it takes over 20 seconds to sharpen a 400 x 400 image. This time is clearly unacceptable for a…

Read More →

Case Studies

To help you better understand how to apply the rules that have been mentioned so far andoptimize your applications, let’s explore a few practical situations and follow the optimization process. In the rest of the chapter we’ll optimize two of the applications developed earlier in the book: the OirMap application we developed in Chapter 11 and the Image application.…

Read More →

Avoid Large Strings

The single most important trick in speeding up string operations is to remember that MidO is not only a function, it’s also a statement. In the following line, the Midt) function returns the third through the tenth characters of a string: subString  m.MidS (originalStrig,3,10) But in the following line, Mid$O is used as’a statement to change ‘part…

Read More →

Simplify the Math

Now we’re going to optimize the code in the loop. There isn’t much you can do other than to replace tl}eAoperator, which raises a number (integer and ‘non-integer) to a power. Raising a number to a non-integer power is accomplished with a rather complicated algorithm, but you can also do this by squaring or cubing a number, which is…

Read More →

Avoid Vectriats

Variants are convenient when you’re putting together a short program to display the ASCn character set or the ASCn values of the function keys, but otherwise, you should avoid variants in your code. They take up much more memory than other data types and can’t be processed immediately. When the compiler encounters them, it must find out their proper…

Read More →

Optimizing VB Code

Code optimization depends on the type of applipttion you’re writing. In l!\06t cases, .you’ll be optimizing’ small, tight sections of code that are executed freqhently (such as loops or frequently called procedure=- Code optimization requires a combination of experience, an eye for detail, and a understanding of the architecture. of the language and how processors work. Seasoned programmers who…

Read More →

Compiler Options

So, now that we have a native code compiler, which produces faster-running executables, you might think that we could just forget all about p-code. Rut the native code compiler comes with a price. It produces longer files that take longer to load, and if you’re distributing your software on the Internet, it will also take longer to download. If…

Read More →

Develop or Buy?

The Visual Basic Compiler’ Visual Basic applications can be executed in two.mo~es: as p-code (from within the Visual Basiq JOE) and as natil’f code (when compiled to EXE files): Prior to version 5, VisualBasic could only ‘produce p-code. Where native code is understood directly by the processor arid executed as is, code is a special’ form of…

Read More →

Optimizing VB Applications

In this chapter, I will present the basics of code optimization and a few tricks for writing faster running code. To demonstrate the importance of code optimization, I will also present a few examples based on applications developed earlier in the book. Visual Basic is the simplest, most popular language for rapid application development, and in most respects, as…

Read More →

Back to Top