手机站
网通分站
电信主站
密 码:
用户名:
当前位置 : 主页>网络编程>Asp.Net编程>列表

Creating a Server Component with VB - Redesigned - Part 2

来源:互联网 作者:西部数码 时间:2008-04-10
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!
Running the code above will produce the following string:

This is an example of using the string-buffering method in place of concatenation

I''''ll let you play around with this code on your own since the article mentioned above should provide a conceptual understanding of what''''s happening here. But, so you won''''t have to apply a string buffer to the example ShowNotes() method code yourself, here''''s the same code fragment covered in this article''''s "Constructing the Return String" section, but using string buffering rather than concatenation. The entire ShowNotes() sample code is also available optimized with string buffering (STEVE: TO EDITOR: Link to the ShowNotesClassOptimizedCode.doc text as a HTML file).

Code Fragment for Using String Buffering to Construct a Return String

    
''''///// CONSTRUCT NOTE TITLES ///////////////////////////////////
    ''''///// Include the beginning table data and font tags
    S1 S2, S3, strTitleDataStart
    S1 S2, S3, strTitleFontStart
    
    ''''///// Get the number of titles stored in the array
    lngArrayCount = UBound(vRecordArray, 2)
    
    ''''///// Set selected NoteID to array index (for not inserting the <A> tag)
    lngNoteIdIndex = (lngNoteID - 1)
    
    ''''///// Loop through array
    For lngIndexCount = 0 To lngArrayCount
    
        ''''///// Include an <A> tag if not the selected NoteID
        If Not lngNoteIdIndex = lngIndexCount Then
            S1 S2, S3, "<A HREF="""
            S1 S2, S3, strURL
            S1 S2, S3, "?ID="
            S1 S2, S3, vRecordArray(ARRAY_NOTE_ID_INDEX, lngIndexCount)
            S1 S2, S3, """>"
        End If
        
        ''''///// Include the note title text from the array
        S1 S2, S3, vRecordArray(ARRAY_TITLE_INDEX, lngIndexCount)
        
        ''''///// Include an </A> tag if not the selected NoteID
        If Not lngNoteIdIndex = lngIndexCount Then S1 S2, S3, "</A>"
        
        ''''///// End the title line with a line break
        S1 S2, S3, "<BR>"
    Next
    
    ''''///// Include the ending font and table data tags
    S1 S2, S3, strTitleFontEnd
    S1 S2, S3, strTitleDataEnd
    
    
    ''''///// CONSTRUCT NOTE TEXT BODY ////////////////////////////////
    ''''///// Include the beginning table data and font tags
    S1 S2, S3, strTextDataStart
    S1 S2, S3, strTextFontStart
    
    ''''///// Include the note text body
    S1 S2, S3, strNoteText
    
    ''''///// Include the ending font table data tags
    S1 S2, S3, strTextFontEnd
    S1 S2, S3, strTextDataEnd
    
    
    ''''///// SEND BACK CONSTRUCTED TEXT IN BUFFER ////////////////////
    ShowNotes = Left$(S2, S3)

Conclusion

The code examples in this article are the main essential processes needed to write large server-side applications like my own EZsite Forum DEV and EZsite Daily Planner. Both applications are available as free trial downloads at my site, http://www.dougdean.com. Please feel free to download either application, without obligation, and explore how the ASP code and method signatures work together. Both trial applications have documented method descriptions that incorporate the processes described in this article.

I also want to acknowledge the many programmers and developers who contact me with information and suggestions about the articles I have written. Your comments are appreciated and I feel fortunate that I can have a venue to ''''brain-dump'''' the server-side information that I acquire.

One other thought I''''d like to share is the issue of transition to Microsoft''''s .NET. At the time this article was published, Beta 2 had just been released and books, magazines, and conferences have all dedicated themselves to the .NET environment. I''''m very happy with C# and have already started coding an application for the .NET environment. One question on my mind was answered at recent conference. Simply stated, the recommendation was to use C# for .NET component development and stay exclusively with VB for COM development. Not mixing the new and old VBs hits a chord with me and I wanted to pass it on to any readers who may share the same intuitions I have about the future direction of server-side component development. COM components written with VB6 will be necessary for quite a while and the thought of having to keep track of two versions of VB inside my head is disconcerting, to say the least. I, for one, will use be using C# for .NET server-side component development and VB6 for server-side COM development.

About the Author

Doug Dean lives in southern California where he manages Doug Dean Software, Inc. His company is dedicated to creating server-side component products. His product line also includes EZsite Forum DEV, EZsite Daily Planner, EZsite Forum 3, EZsite Calendar, and EZsite WebNotes. Other helpful articles on ASP/VB component issues can be found at http://www.dougdean.com. Contact Doug Dean at dougdean@deltanet.com.

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!