Porting ASP code to VB COM components (3)

Source: Internet
Author: User
Tags visual studio
Working with subroutines and functions
Author: green Apple Computer Studio
A quick question: why is there so little code in the ASP book that discusses using subroutines and functions?
While writing ASP code in one line is simpler, coding in the form of a program has many benefits.
First, non-programmatic code is not easy to migrate to visual Basic. Maybe you don't have the plan at the moment, but someday you will
The performance or scalability to migrate some code into the component.
Second, the program is running faster. The maximum consumption of ASP performance is context conversion, each time from the ASP code area <%% > to the unformatted
Occurs when HTML is in place. Because you do not encode a context conversion within the program, you won't feel this consumption. In addition, ASP's
Buffers also show that when a subroutine clicks on a page with programmatic code, it makes a big difference. This is an ASP application that uses programmatic code
The necessary part of "Hello World":
Private Sub Main ()
Response.Write "Hello world!"
End Sub
Call Main
For the sake of completeness, I included a small example of context conversion in the program. If you test this code, it will run, but please
Do not do this within your own application.
<%@ language=vbscript% >
<%
Private Sub Dostuff ()
% >
This is < b > HTML text! </b >
<%
End Sub
% >
< HTML >
< head >
< META name= "generator" content= "Microsoft Visual Studio 6.0" >
< BODY >
< P ><% call Dostuff% ></p >
</body >
Programmatic code has some other benefits as well. First you'll find it easier to reuse the parts of the code that are included in the program. Secondly, to
Fewer lines of code are required to achieve the same purpose. Third, you will begin to develop a large reusable code base. At first it's
The form is. inc file, and finally your own normal COM component looks just as good as Jeff Gordon (a famous racing player).
Porting your code.
There are a few things that are as simple as porting code from VBScript to Visual Basic. Generally, you need to remove the code and increase the data type.
Sometimes, you can also apply some more efficient algorithms in Visual Basic, but you must first ensure that your code works correctly.
In our application example, some simple code will be ported to two visual Basic COM components. Add some HTML
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.