But first, the code assigns the default values to the HTML style variables if intStyleID is set to zero. The code also conditionally sets the HTML style variables from a database record if intStyleID is set to a value other than zero.
''''///// SET NOTE STYLE PROPERTIES ///////////////////////////////
If intStyleID = 0 Then
''''///// SET NOTE STYLE TO DEFAULT VALUES
''''///// Note Title Default Style Values
strTitleDataStart = "<TD WIDTH=""74"" NOWRAP VALIGN=""top"">"
strTitleFontStart = "<FONT FACE=""Verdana"" SIZE=""1"" COLOR=""GRAY"">"
strTitleFontEnd = "</FONT>"
strTitleDataEnd = "</TD>"
''''///// Note Text Default Style Values
strTextDataStart = "<TD WIDTH=""124"" VALIGN=""top"" BGCOLOR=""#EFEFEF"">"
strTextFontStart = "<FONT FACE=""Verdana"" SIZE=""1"" COLOR=""NAVY"">"
strTextFontEnd = "</FONT>"
strTextDataEnd = "</TD>"
The database code should be more than familiar to you now. All the fields from the NoteStyleTable are being retrieved from the record that is indicated by the intStyleID value. The GetRows() method is not used since we''''re not looping through a set of records. Notice that this code lacks the error-handling code demonstrated in the note title and text database code. It''''s left out here for clarity sake, but you''''d want to include error handling since a nonexistent intStyleID value could be sent.
Else
''''///// SET NOTE STYLE FROM VALUES IN DATABASE
sql = "SELECT * FROM NoteStyleTable WHERE intStyleID = " & intStyleID
objCmd.CommandText = sql
objCmd.CommandType = adCmdText
Set objCmd.ActiveConnection = objConn
Rs.Open objCmd
''''///// Note title database style values
strTitleDataStart = "" & Rs.Fields("strTitleDataStart")
strTitleFontStart = "" & Rs.Fields("strTitleFontStart")
strTitleFontEnd = "" & Rs.Fields("strTitleFontEnd")
strTitleDataEnd = "" & Rs.Fields("strTitleDataEnd")
''''///// Note text database style values
strTextDataStart = "" & Rs.Fields("strTextDataStart")
strTextFontStart = "" & Rs.Fields("strTextFontStart")
strTextFontEnd = "" & Rs.Fields("strTextFontEnd")
strTextDataEnd = "" & Rs.Fields("strTextDataEnd")
''''///// Close this Recordset
Rs.Close
End If
Here''''s the string that is returned from this example code when the default style values are used.
The above code returns the following: Another option is to have multiple default settings that are checked with ElseIf statements within the If/Then code. By doing this, a developer can set the intStyleID method parameter to negative values (-1, -2, -3, etc.) for various other default settings and positive values (1, 2, 3, etc.) for customizable settings that are stored in the database.
<TD WIDTH="74" NOWRAP VALIGN="top">
<FONT FACE="Verdana" SIZE="1" COLOR="GRAY">Test</FONT>
</TD>
<TD WIDTH="124" VALIGN="top" BGCOLOR="#EFEFEF">
<FONT FACE="Verdana" SIZE="1" COLOR="NAVY">Another Test</FONT>
</TD>
The code fragment in this section uses concatenation to build up the string that fuses the HTML style variable values and the database note information. In the next code section, string buffering will be demonstrated as an optional, and optimal, replacement for VB''''s native string concatenation.
The code here assigns the VB construct vbCrLf to the ends of each HTML tag so that the HTML source code will be easier to read. You can remove these line breaks to save a few bits of HTML source code space at the expense of clarity. They are optional.
The basic structure of this code appears below. Notice that the first table we construct is the note titles table. This is where our vRecordArray will be used. Since multiple note titles are retrieved from the database, we''''ll loop through them while constructing an <A> HTML tag with a query string set to each title''''s NoteID. We''''ll also omit the <A> tags for the title that was selected by the user.
文章整理:西部数码--专业提供域名注册、虚拟主机服务
CONSTRUCT THE NOTE TITLES TABLE
Include the beginning table data and font tags
Loop through the vRecordArray array
Include an <A> tag if not the selected NoteID
Include the note title text from the array
Include an </A> tag if not the selected NoteID
End the title line with a line break
End looping
Include the ending font and table data tags
CONSTRUCT NOTE TEXT BODY
Include the beginning table data and font tags
Include the note text body
Include the ending font table data tags
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




