NoteStyleTable
AutoStyleID AutoNumber
intStyleID Number
strTitleDataStart Text
strTitleFontStart Text
strTitleFontEnd Text
strTitleDataEnd Text
strTextDataStart Text
strTextFontStart Text
strTextFontEnd Text
strTextDataEnd Text
Here are a few of the alternative styles stored in the example database:
Now that the functioning of the example application has been all mapped out; all that''''s needed is the VB method code that will produce the return string that displays our note titles and text in HTML formatted code.
The VB Environment SetupThe VB example code that we''''ll be covering in this article will use the following names:
VB Code: Project name: NoteProject Class name: NoteClass Method name: ShowNotes ASP Code: ASP file name: NoteExample.aspThe typical way to start a VB DLL for server-side use is to select the ActiveX DLL icon in the VB Projects window. After changing the Project and Class names to NoteProject and NoteClass for our example code, you can use an ASP file for testing and debugging your code. To have VB call an ASP file when the code is run, select the "Projects/NoteProject Properties..." from the VB menu and then select the "Debugging" tab. Select "Start browser at URL:" and enter the path and the name for an ASP file (NoteExample.asp for our example file). By instantiating NoteClass in the NoteExample.asp file and calling the components method, you can test the VB code by selecting the "Run" option from VB.
Here''''s another example of ASP file code that will successfully call our example VB method: There are a number of ways to begin coding a server-side DLL component in VB,, and I''''d like to demonstrate an alternative way that I have found useful. You can skip this section if you prefer to start your VB coding as an ActiveX DLL project type and you will not have to change the project and class settings after starting it alternatively as a Standard EXE project type. I added this section for those who like to experiment with different ways to test and debug their initial server-side DLL code.
''''///// Instantiate the component object
Set objReference = Server.CreateObject("NoteProject.NoteClass")
''''///// Call the components method and store the returned string
strMethodReturn = objReference.ShowNotes(1)
''''///// Send the returned string to the visiting browser
Response.Write(strMethodReturn)
''''///// Clean up
Set objReference = Nothing
To make the initial code easy to test and debug, start a Standard EXE from VB and change the default Project1 project name to NoteProject. Next, add a class module (Project/Add Class Module from the VB menu) and name it NoteClass. Save both the project and class files in a directory of your choosing.
Since this is a Standard EXE project, we''''ll have to eventually change some of the settings of the class and project so we can use it as a server-side DLL. But for now we''''ll use the Standard EXE''''s default Form1 code to test our code instead of using an ASP file.
The method of our example class (ShowNotes) will return a string that contains data with HTML formatting, so eventually you''''ll want to test your code by calling the class method from an ASP file. But it''''s sometimes faster to initially test your code by sending the method''''s return string to the VB Immediate window for quicker debugging. This method even has the advantage of developing a server-side DLL on a computer system regardless of whether it has ASP installed on it or not.
To set up VB to test your code in this fashion, select the Form1 object (created by VB when you selected Standard EXE as a new project type) and double click the form. Place the following code within the Form1 code window. After you enter the code for the example class, you''''ll be able to run the code and have the method''''s return string displayed in VB''''s Immediate window. From there you can cut and paste the string into an HTML editor for initial changes before actually calling the classes method from an ASP file.
Form Code Used to Test Method Class
Private Sub Form_Load()
Dim objReference As New NoteProject.NoteClass
Debug.Print objReference.ShowNotes(1)
End
End Sub
I have found that it takes about 5 seconds to do this when using an HTML editor like Allaire''''s HomeSite. I just run the VB code and then, while holding down the Control key, hit the "G," "A," and "X" keys sequentially. This displays VB''''s Immediate window, selects the class method''''s return string, and removes it while placing it in Windows'''' memory work space. I then paste it to my HomeSite''''s editor to see what it looks like rendered in a browser.
When you''''re ready to start testing your VB code by calling the Class method from an ASP file, remove the Form1 form by right clicking its name in the Project Explorer window and selecting "Remove Form1". Go to the VB "Projects/NoteProject Properties..." menu selections and in the Project Properties window change the Standard EXE value in the drop-down box to ActiveX DLL. Change the "Single Threaded" value to "Apartment Threaded" in the Threading Model area on the same window. The drop-down list labeled ''''Startup Object:'''' should have "(None)" selected. Also, make sure that "Unattended Execution" and "Upgrade ActiveX Controls" are selected. VB will respond with "Project ''''Start Mode'''' property has been changed" when you select the Project Properties OK button. Just click OK in this warning window. Select the NoteClass name in the Project Explorer and change its Instancing value in the Properties window to "5 - MultiUse". You may want to go back to the Project Properties window and select the "Retain In Memory" box, which may only now be selectable. Save your new DLL project, and you''''re ready to run your VB code from an ASP file.
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




