﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-★Daniel's Blog★-文章分类-VB,VB.NET</title><link>http://www.blogjava.net/Daniel2005/category/4915.html</link><description>URL:http://www.blogjava.net/Daniel2005</description><language>zh-cn</language><lastBuildDate>Mon, 13 Aug 2007 10:40:45 GMT</lastBuildDate><pubDate>Mon, 13 Aug 2007 10:40:45 GMT</pubDate><ttl>60</ttl><item><title>VB编写管道程序</title><link>http://www.blogjava.net/Daniel2005/articles/135463.html</link><dc:creator>泌鲁沙夫</dc:creator><author>泌鲁沙夫</author><pubDate>Thu, 09 Aug 2007 05:17:00 GMT</pubDate><guid>http://www.blogjava.net/Daniel2005/articles/135463.html</guid><wfw:comment>http://www.blogjava.net/Daniel2005/comments/135463.html</wfw:comment><comments>http://www.blogjava.net/Daniel2005/articles/135463.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Daniel2005/comments/commentRss/135463.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Daniel2005/services/trackbacks/135463.html</trackback:ping><description><![CDATA[<p>'---------------------------------------------------<br>' Module CaptureConsoleOutput<br>'<br>' Purpose: Excute a console app. &amp; capture output<br>'<br>' Author: daniel chen<br>' E-mail: <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#100;&#97;&#110;&#105;&#101;&#108;&#46;&#99;&#104;&#101;&#110;&#64;&#115;&#117;&#114;&#114;&#101;&#121;&#116;&#101;&#99;&#104;&#110;&#111;&#108;&#111;&#103;&#121;&#46;&#99;&#111;&#109;">daniel.chen@surreytechnology.com</a><br>'<br>' Date: July 10, 2007<br>'---------------------------------------------------<br>Option Explicit<br>' Contants<br>Private Const STARTF_USESHOWWINDOW&nbsp;&nbsp;&nbsp;&nbsp; As Long = &amp;H1<br>Private Const STARTF_USESTDHANDLES&nbsp;&nbsp;&nbsp;&nbsp; As Long = &amp;H100<br>Private Const SW_HIDE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; As Integer = 0<br>' Types<br>Private Type SECURITY_ATTRIBUTES<br>&nbsp;&nbsp;&nbsp; nLength&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; As Long<br>&nbsp;&nbsp;&nbsp; lpSecurityDescriptor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; As Long<br>&nbsp;&nbsp;&nbsp; bInheritHandle&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; As Long<br>End Type<br>Private Type STARTUPINFO<br>&nbsp;&nbsp;&nbsp; cb&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; As Long<br>&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lpNumberOfBytesRead As Long, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lpOverlapped As Any) As Long<br>Private Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" (ByVal lpApplicationName As String, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ByVal lpCommandLine As String, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb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bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lpStartupInfo As STARTUPINFO, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lpProcessInformation As PROCESS_INFORMATION) As Long<br>Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long<br>Private Declare Function TerminateProcess Lib "kernel32" _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (ByVal hProcess As Long, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ByVal uExitCode As Long) As Long<br>Declare Function EnumWindows Lib "user32" (ByVal wndenmprc As Long, ByVal lParam As Long) As Long<br>Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long<br>Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long<br>Public Const WM_CLOSE = &amp;H10</p>
<p>Private Target As String</p>
<p>'---------------------------------------------------<br>' Call this sub to execute and capture a console app.<br>' Ex: Call ExecAndCapture("ping localhost", Text1)<br>Public Sub ExecAndCapture(ByVal sCommandLine As String, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cTextBox As StatusBar, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ByVal status_flag As Integer, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Optional ByVal sStartInFolder As String = vbNullString)&nbsp;&nbsp;&nbsp; '--add by daniel for set status_flag if is 1 then ok else is 2 then closeHandle</p>
<p>Const BUFSIZE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; As Long = 1024 * 10<br>Dim hPipeRead&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; As Long<br>Dim hPipeWrite&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; As Long<br>Dim sa&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; As SECURITY_ATTRIBUTES<br>Dim si&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; As STARTUPINFO<br>Dim pi&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; As PROCESS_INFORMATION<br>Dim baOutput(BUFSIZE) As Byte<br>Dim sOutput&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; As String<br>Dim lBytesRead&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; As Long<br>&nbsp;&nbsp;&nbsp; <br>If status_flag = 1 Then<br>&nbsp;&nbsp;&nbsp; With sa<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .nLength = Len(sa)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .bInheritHandle = 1&nbsp;&nbsp;&nbsp; ' get inheritable pipe handles<br>&nbsp;&nbsp;&nbsp; End With 'SA<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; If CreatePipe(hPipeRead, hPipeWrite, sa, 0) = 0 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit Sub<br>&nbsp;&nbsp;&nbsp; End If</p>
<p>&nbsp;&nbsp;&nbsp; With si<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .cb = Len(si)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .dwFlags = STARTF_USESHOWWINDOW Or STARTF_USESTDHANDLES<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .wShowWindow = SW_HIDE&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' hide the window<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .hStdOutput = hPipeWrite<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .hStdError = hPipeWrite<br>&nbsp;&nbsp;&nbsp; End With 'SI<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; If CreateProcess(vbNullString, sCommandLine, ByVal 0&amp;, ByVal 0&amp;, 1, 0&amp;, ByVal 0&amp;, sStartInFolder, si, pi) Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Call CloseHandle(hPipeWrite)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Call CloseHandle(pi.hThread)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hPipeWrite = 0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DoEvents<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If status_flag = 1 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If ReadFile(hPipeRead, baOutput(0), BUFSIZE, lBytesRead, ByVal 0&amp;) = 0 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Exit Do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sOutput = Left$(StrConv(baOutput(), vbUnicode), lBytesRead)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If status_flag = 1 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cTextBox.Panels(2).Text = sOutput<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ElseIf status_flag = 2 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cTextBox.Panels(2).Text = ""<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Call CloseHandle(pi.hProcess)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ElseIf status_flag = 2 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cTextBox.Panels(2).Text = ""<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Call CloseHandle(pi.hProcess)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Loop<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Call CloseHandle(pi.hProcess)<br>&nbsp;&nbsp;&nbsp; End If<br>ElseIf status_flag = 2 Then<br>&nbsp;&nbsp;&nbsp; cTextBox.Panels(2).Text = ""<br>&nbsp;&nbsp;&nbsp; pi.hThread = 0<br>&nbsp;&nbsp;&nbsp; pi.hProcess = 0<br>End If<br>&nbsp;&nbsp;&nbsp; ' To make sure...<br>&nbsp;&nbsp;&nbsp; Call CloseHandle(hPipeRead)<br>&nbsp;&nbsp;&nbsp; Call CloseHandle(hPipeWrite)</p>
<p>End Sub</p>
<p><br>' Check a returned task to see if we should<br>' kill it.<br>Public Function EnumCallback(ByVal app_hWnd As Long, ByVal param As Long) As Long<br>Dim buf As String * 256<br>Dim title As String<br>Dim length As Long</p>
<p>&nbsp;&nbsp;&nbsp; ' Get the window's title.<br>&nbsp;&nbsp;&nbsp; length = GetWindowText(app_hWnd, buf, Len(buf))<br>&nbsp;&nbsp;&nbsp; title = Left$(buf, length)</p>
<p>&nbsp;&nbsp;&nbsp; ' See if this is the target window.<br>&nbsp;&nbsp;&nbsp; If InStr(title, Target) &lt;&gt; 0 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' Kill the window.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SendMessage app_hWnd, WM_CLOSE, 0, 0<br>&nbsp;&nbsp;&nbsp; End If<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; ' Continue searching.<br>&nbsp;&nbsp;&nbsp; EnumCallback = 1<br>End Function</p>
<p>' Ask Windows for the list of tasks.<br>Public Sub TerminateTask(app_name As String)<br>&nbsp;&nbsp;&nbsp; Target = app_name<br>&nbsp;&nbsp;&nbsp; EnumWindows AddressOf EnumCallback, 0<br>End Sub</p>
<p>&nbsp;</p>
<p>Call ExecAndCapture(strpingip, stbaccess, 1)&nbsp;&nbsp;&nbsp;</p>
<img src ="http://www.blogjava.net/Daniel2005/aggbug/135463.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Daniel2005/" target="_blank">泌鲁沙夫</a> 2007-08-09 13:17 <a href="http://www.blogjava.net/Daniel2005/articles/135463.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>WEB打印方式!</title><link>http://www.blogjava.net/Daniel2005/articles/125849.html</link><dc:creator>泌鲁沙夫</dc:creator><author>泌鲁沙夫</author><pubDate>Fri, 22 Jun 2007 07:21:00 GMT</pubDate><guid>http://www.blogjava.net/Daniel2005/articles/125849.html</guid><wfw:comment>http://www.blogjava.net/Daniel2005/comments/125849.html</wfw:comment><comments>http://www.blogjava.net/Daniel2005/articles/125849.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Daniel2005/comments/commentRss/125849.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Daniel2005/services/trackbacks/125849.html</trackback:ping><description><![CDATA[<p><span style="COLOR: red">1).NET &nbsp; Framework &nbsp; 类库</span> &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; PrinterSettings &nbsp; 成员请参见 &nbsp; <br>&nbsp; PrinterSettings &nbsp; 类 &nbsp; | &nbsp; System.Drawing.Printing &nbsp; 命名空间 &nbsp; | &nbsp; C++ &nbsp; 托管扩展编程 &nbsp; &nbsp; <br>&nbsp; PrinterSettings &nbsp; 概述 &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; 公共构造函数 &nbsp; <br>&nbsp; PrinterSettings &nbsp; 构造函数 &nbsp; 初始化 &nbsp; PrinterSettings &nbsp; 类的新实例。 &nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; 公共属性 &nbsp; <br>&nbsp; CanDuplex &nbsp; 获取指示打印机是否支持双面打印的值。 &nbsp; &nbsp; <br>&nbsp; Collate &nbsp; 获取或设置一个值，该值指示打印文档是否逐份打印。 &nbsp; &nbsp; <br>&nbsp; Copies &nbsp; 获取或设置要打印的文档份数。 &nbsp; &nbsp; <br>&nbsp; DefaultPageSettings &nbsp; 获取此打印机的默认页设置。 &nbsp; &nbsp; <br>&nbsp; Duplex &nbsp; 获取或设置双面打印的打印机设置。 &nbsp; &nbsp; <br>&nbsp; FromPage &nbsp; 获取或设置要打印的第一页的页码。 &nbsp; &nbsp; <br>&nbsp; InstalledPrinters &nbsp; 获取安装在计算机上所有打印机的名称。 &nbsp; &nbsp; <br>&nbsp; IsDefaultPrinter &nbsp; 获取一个值，该值指示 &nbsp; PrinterName &nbsp; 属性是否指定默认打印机（用户显式设置 &nbsp; PrinterName &nbsp; 的情况除外）。 &nbsp; &nbsp; <br>&nbsp; IsPlotter &nbsp; 获取指示该打印机是否是绘图仪的值。 &nbsp; &nbsp; <br>&nbsp; IsValid &nbsp; 获取一个值，该值指示 &nbsp; PrinterName &nbsp; 属性是否指定了有效的打印机。 &nbsp; &nbsp; <br>&nbsp; LandscapeAngle &nbsp; 获取旋转纵向方向以生成横向方向的角度，以度为单位。 &nbsp; &nbsp; <br>&nbsp; MaximumCopies &nbsp; 获取打印机允许一次打印的最多份数。 &nbsp; &nbsp; <br>&nbsp; MaximumPage &nbsp; 获取或设置可以在 &nbsp; PrintDialog &nbsp; 中选定的最大的 &nbsp; FromPage &nbsp; 或 &nbsp; ToPage。 &nbsp; &nbsp; <br>&nbsp; MinimumPage &nbsp; 获取或设置可以在 &nbsp; PrintDialog &nbsp; 中选定的最小的 &nbsp; FromPage &nbsp; 或 &nbsp; ToPage。 &nbsp; &nbsp; <br>&nbsp; PaperSizes &nbsp; 获取该打印机支持的纸张大小。 &nbsp; &nbsp; <br>&nbsp; PaperSources &nbsp; 获取打印机上可用的纸张来源纸盒。 &nbsp; &nbsp; <br>&nbsp; PrinterName &nbsp; 获取或设置要使用的打印机的名称。 &nbsp; &nbsp; <br>&nbsp; PrinterResolutions &nbsp; 获取该打印机支持的所有分辨率。 &nbsp; &nbsp; <br>&nbsp; PrintRange &nbsp; 获取或设置用户已指定要打印的页码。 &nbsp; &nbsp; <br>&nbsp; PrintToFile &nbsp; 获取或设置一个值，该值指示打印输出是否发送到文件，而不发送到端口。 &nbsp; &nbsp; <br>&nbsp; SupportsColor &nbsp; 获取指示该打印机是否支持彩色打印的值。 &nbsp; &nbsp; <br>&nbsp; ToPage &nbsp; 获取或设置要打印的最后一页的页码。 &nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; 公共方法 &nbsp; <br>&nbsp; Clone &nbsp; 创建此 &nbsp; PrinterSettings &nbsp; 对象的一个副本。 &nbsp; &nbsp; <br>&nbsp; CreateMeasurementGraphics &nbsp; 返回 &nbsp; Graphics &nbsp; 对象，该对象包含创建 &nbsp; PrintDocument &nbsp; 时有用的打印机信息，例如，打印机的 &nbsp; TextMetric &nbsp; 对象。 &nbsp; &nbsp; <br>&nbsp; Equals（从 &nbsp; Object &nbsp; 继承） &nbsp; 已重载。确定两个 &nbsp; Object &nbsp; 实例是否相等。 &nbsp; &nbsp; <br>&nbsp; GetHashCode（从 &nbsp; Object &nbsp; 继承） &nbsp; 用作特定类型的哈希函数，适合在哈希算法和数据结构（如哈希表）中使用。 &nbsp; &nbsp; <br>&nbsp; GetHdevmode &nbsp; 已重载。创建与打印机设置相对应的 &nbsp; DEVMODE &nbsp; 结构的句柄。 &nbsp; &nbsp; <br>&nbsp; GetHdevnames &nbsp; 创建与打印机设置相对应的 &nbsp; DEVNAMES &nbsp; 结构的句柄。 &nbsp; &nbsp; <br>&nbsp; GetType（从 &nbsp; Object &nbsp; 继承） &nbsp; 获取当前实例的 &nbsp; Type。 &nbsp; &nbsp; <br>&nbsp; SetHdevmode &nbsp; 将相关信息从给定句柄复制到 &nbsp; PrinterSettings &nbsp; 中。 &nbsp; &nbsp; <br>&nbsp; SetHdevnames &nbsp; 将相关信息从给定句柄复制到 &nbsp; PrinterSettings &nbsp; 中。 &nbsp; &nbsp; <br>&nbsp; ToString &nbsp; 已重写。参见 &nbsp; Object.ToString。 &nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; 受保护的方法 &nbsp; <br>&nbsp; Finalize（从 &nbsp; Object &nbsp; 继承） &nbsp; 已重写。允许 &nbsp; Object &nbsp; 在&#8220;垃圾回收&#8221;回收 &nbsp; Object &nbsp; 之前尝试释放资源并执行其他清理操作。 &nbsp; &nbsp; <br>&nbsp; 在 &nbsp; C# &nbsp; 和 &nbsp; C++ &nbsp; 中，使用析构函数语法来表示终结程序。 &nbsp; <br>&nbsp; &nbsp; &nbsp; <br>&nbsp; MemberwiseClone（从 &nbsp; Object &nbsp; 继承） &nbsp; 创建当前 &nbsp; Object &nbsp; 的浅表副本。 &nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; 请参见 &nbsp; <br>&nbsp; PrinterSettings &nbsp; 类 &nbsp; | &nbsp; System.Drawing.Printing &nbsp; 命名空间 &nbsp; | &nbsp; C++ &nbsp; 托管扩展编程</p>
<span style="COLOR: red">2)1、控制"纵打"、 横打&#8221;和&#8220;页面的边距。 <br>（1）<font color=#000000>&lt;OBJECT id="factory" codeBase="smsx.cab" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" viewastext&gt;&lt;/OBJECT&gt; </font><br><span style="COLOR: #000000">&lt;</span></span>script defer&gt; <br>function SetPrintSettings() { <br>　// -- advanced features <br>　factory.printing.SetMarginMeasure(2) // measure margins in inches <br>　factory.SetPageRange(false, 1, 3) // need pages from 1 to 3 <br>　factory.printing.printer = "HP DeskJet 870C" <br>　factory.printing.copies = 2 <br>　factory.printing.collate = true <br>　factory.printing.paperSize = "A4" <br>　factory.printing.paperSource = "Manual feed" <br><br>　// -- basic features <br>　factory.printing.header = "This is MeadCo" <br>　factory.printing.footer = "Advanced Printing by ScriptX" <br>　factory.printing.portrait = false <br>　factory.printing.leftMargin = 1.0 <br>　factory.printing.topMargin = 1.0 <br>　factory.printing.rightMargin = 1.0 <br>　factory.printing.bottomMargin = 1.0 <br>} <br>&lt;/script&gt; <br><br><span style="COLOR: red">（3）</span> <br>&lt;script language="javascript"&gt; <br>　　function printsetup(){ <br>　　// 打印页面设置 <br>　　wb.execwb(8,1); <br>　　} <br>　　function printpreview(){ <br>　　// 打印页面预览 <br>　　　　 <br>　　wb.execwb(7,1); <br>　　　　　 <br>　　　　 <br>　　} <br><br>　　function printit() <br>　　{ <br>　　if (confirm('确定打印吗？')) { <br>　　wb.execwb(6,6) <br>　　} <br>　　} <br>　　&lt;/script&gt; <br>&lt;/head&gt; <br>&lt;body&gt; <br>&lt;OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=wb name=wb width=0&gt;&lt;/OBJECT&gt; <br>&lt;input type=button name=button_print value="打印" onclick="javascript:printit()"&gt; <br>&lt;input type=button　name=button_setup value="打印页面设置" onclick="javascript:printsetup();"&gt; <br>&lt;input type=button　name=button_show value="打印预览" onclick="javascript:printpreview();"&gt; <br>&lt;input type=button name=button_fh value="关闭" onclick="javascript:window.close();"&gt; <br><br>
<img src ="http://www.blogjava.net/Daniel2005/aggbug/125849.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Daniel2005/" target="_blank">泌鲁沙夫</a> 2007-06-22 15:21 <a href="http://www.blogjava.net/Daniel2005/articles/125849.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Error while trying to run project: Unable to start debugging on the web server. You do not have permission to debug the application. The URL for this project is in the Internet zone. Click Help for more information.</title><link>http://www.blogjava.net/Daniel2005/articles/125539.html</link><dc:creator>泌鲁沙夫</dc:creator><author>泌鲁沙夫</author><pubDate>Thu, 21 Jun 2007 05:35:00 GMT</pubDate><guid>http://www.blogjava.net/Daniel2005/articles/125539.html</guid><wfw:comment>http://www.blogjava.net/Daniel2005/comments/125539.html</wfw:comment><comments>http://www.blogjava.net/Daniel2005/articles/125539.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Daniel2005/comments/commentRss/125539.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Daniel2005/services/trackbacks/125539.html</trackback:ping><description><![CDATA[<h2><a id=viewpost_ascx_TitleUrl title="Title of this entry." href="http://geekswithblogs.net/ranganh/archive/2005/12/30/64446.aspx"><u><font color=#810081>"Unable to start debugging on the web server. You do not have permission to debug the application. The URL for this project is in the Internet zone." </font></u></a></h2>
<font face=Tahoma><font size=2><font color=#000080><span style="FONT-FAMILY: trebuchet ms">You may receive the error "Error while trying to run project: Unable to start debugging on the web server. You do not have permission to debug the application. The URL for this project is in the Internet zone. Click Help for more information."</span><br><span style="FONT-FAMILY: trebuchet ms"></span><br><span style="FONT-FAMILY: trebuchet ms">This is one of the various errors that appear when you are debugging and may haunt you until you do the following fix:-</span><br><span style="FONT-FAMILY: trebuchet ms"></span><br></font></font></font><font face=Tahoma><font size=2><font color=#000080><strong><span style="FONT-FAMILY: trebuchet ms">1. In the Internet Explorer, "Tools" Menu, select "Internet Options".</span><br><span style="FONT-FAMILY: trebuchet ms"></span><br><span style="FONT-FAMILY: trebuchet ms">2. Switch to "Security" Tab.</span><br><span style="FONT-FAMILY: trebuchet ms"></span><br><span style="FONT-FAMILY: trebuchet ms">3. Click on "Internet" (The Globe Icon. Its actually the default selected).</span><br><span style="FONT-FAMILY: trebuchet ms"></span><br><span style="FONT-FAMILY: trebuchet ms">4. Click on "Custom Level" in the bottom.</span><br><span style="FONT-FAMILY: trebuchet ms"></span><br><span style="FONT-FAMILY: trebuchet ms">5. Scroll down to find the "User Authentication" section.</span><br><span style="FONT-FAMILY: trebuchet ms"></span><br><span style="FONT-FAMILY: trebuchet ms">6. Select "Automatic logon with current username and password".</span><br><span style="FONT-FAMILY: trebuchet ms"></span><br><span style="FONT-FAMILY: trebuchet ms">7. Click "Ok" twice to exit.</span><br><span style="FONT-FAMILY: trebuchet ms"></span><br></strong><span style="FONT-FAMILY: trebuchet ms">This should solve the issue.</span><br><span style="FONT-FAMILY: Trebuchet MS"></span><br><span style="FONT-FAMILY: Trebuchet MS">Please note that this resolution is specific only if you get the exact error message as mentioned in the beginning of this article. </span><span style="FONT-FAMILY: Trebuchet MS">There are various reasons you get the "Unable to start debugging on the webserver". For a complete list of solutions, please check <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vsdebug.asp"><u><font color=#0000ff>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vsdebug.asp</font></u></a></span></font></font></font>
<img src ="http://www.blogjava.net/Daniel2005/aggbug/125539.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Daniel2005/" target="_blank">泌鲁沙夫</a> 2007-06-21 13:35 <a href="http://www.blogjava.net/Daniel2005/articles/125539.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如何將Excel文件导入到Access!</title><link>http://www.blogjava.net/Daniel2005/articles/125306.html</link><dc:creator>泌鲁沙夫</dc:creator><author>泌鲁沙夫</author><pubDate>Wed, 20 Jun 2007 04:04:00 GMT</pubDate><guid>http://www.blogjava.net/Daniel2005/articles/125306.html</guid><wfw:comment>http://www.blogjava.net/Daniel2005/comments/125306.html</wfw:comment><comments>http://www.blogjava.net/Daniel2005/articles/125306.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Daniel2005/comments/commentRss/125306.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Daniel2005/services/trackbacks/125306.html</trackback:ping><description><![CDATA[下面我已將程序代码做成模块，只要导入必要之参数即可！ &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; 此一模块共有四个参数： &nbsp; <br>&nbsp; 1、sSheetName：要导出资料的文件名称 &nbsp; (Sheet &nbsp; name)，例如 &nbsp; Sheet1 &nbsp; <br>&nbsp; 2、sExcelPath：要导出资料的 &nbsp; Excel &nbsp; 档案路径名称 &nbsp; (Workbook &nbsp; path)，例如 &nbsp; C:\book1.xls &nbsp; <br>&nbsp; 3、sAccessTable：要导入的 &nbsp; Access &nbsp; Table &nbsp; 名称，例如 &nbsp; TestTable &nbsp; <br>&nbsp; 4、sAccessDBPath：要导入的 &nbsp; Access &nbsp; 档案路径名称，例如 &nbsp; C:\Test.mdb &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; 在声明中加入以下： &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; Private &nbsp; Sub &nbsp; ExportExcelSheetToAccess(sSheetName &nbsp; As &nbsp; String, &nbsp; _ &nbsp; <br>&nbsp; sExcelPath &nbsp; As &nbsp; String, &nbsp; sAccessTable &nbsp; As &nbsp; String, &nbsp; sAccessDBPath &nbsp; As &nbsp; String) &nbsp; <br>&nbsp; Dim &nbsp; db &nbsp; As &nbsp; Database &nbsp; <br>&nbsp; Dim &nbsp; rs &nbsp; As &nbsp; Recordset &nbsp; <br>&nbsp; Set &nbsp; db &nbsp; = &nbsp; OpenDatabase(sExcelPath, &nbsp; True, &nbsp; False, &nbsp; "Excel &nbsp; 5.0") &nbsp; <br>&nbsp; Call &nbsp; db.Execute("Select &nbsp; * &nbsp; into &nbsp; [;database=" &nbsp; &amp; &nbsp; sAccessDBPath &nbsp; &amp; &nbsp; "]." &nbsp; &amp; &nbsp; _ &nbsp; <br>&nbsp; sAccessTable &nbsp; &amp; &nbsp; " &nbsp; FROM &nbsp; [" &nbsp; &amp; &nbsp; sSheetName &nbsp; &amp; &nbsp; "$]") &nbsp; <br>&nbsp; MsgBox &nbsp; "Table &nbsp; exported &nbsp; successfully.", &nbsp; vbInformation, &nbsp; "Yams" &nbsp; <br>&nbsp; End &nbsp; Sub &nbsp; <br>&nbsp; 使用范例如下：將 &nbsp; C:\book1.xls &nbsp; 中的 &nbsp; Sheet1 &nbsp; 导入 &nbsp; C:\Test.mdb &nbsp; 成为 &nbsp; TestTable &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; ExportExcelSheetToAccess &nbsp; "Sheet1", &nbsp; "C:\book1.xls", &nbsp; "TestTable", &nbsp; "C:\Test.mdb" <br><br>OR<br><br>Dim &nbsp; cn &nbsp; As &nbsp; New &nbsp; ADODB.Connection &nbsp; '&amp;yen;&amp;acute;&amp;para;}execl &nbsp; <br>&nbsp; Dim &nbsp; Con &nbsp; As &nbsp; New &nbsp; ADODB.Connection &nbsp; '&amp;yen;&amp;acute;&amp;para;}access &nbsp; <br>&nbsp; Dim &nbsp; rs &nbsp; As &nbsp; New &nbsp; Recordset &nbsp; '&amp;brvbar;s&amp;Agrave;xexecl&amp;ordf;&amp;ordm;&amp;frac14;&amp;AElig;&amp;frac34;&amp;Uacute; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Con.ConnectionString &nbsp; = &nbsp; "Provider=Microsoft.Jet.OLEDB.4.0;Data &nbsp; Source=D:\My &nbsp; Vbp\MyDataBase\DataBase.mdb;Persist &nbsp; Security &nbsp; Info=False" &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cn.ConnectionString &nbsp; = &nbsp; "Provider=Microsoft.Jet.OLEDB.4.0;Persist &nbsp; Security &nbsp; Info=false;Data &nbsp; Source=C:\Documents &nbsp; and &nbsp; Settings\zhangshuai\My &nbsp; Documents\My &nbsp; Work\ExeclToSQL.xls;Extended &nbsp; Properties='Excel &nbsp; 8.0;HDR=Yes;IMEX=1'" &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cn.Open &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Con.Open &nbsp; <br>&nbsp; ' &nbsp; &nbsp; &nbsp; &nbsp; rs1.Open &nbsp; "Select &nbsp; * &nbsp; From &nbsp; TableName", &nbsp; con, &nbsp; 1, &nbsp; 1 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.Open &nbsp; "select &nbsp; * &nbsp; From &nbsp; [Sheet1$]", &nbsp; cn, &nbsp; 1, &nbsp; 1 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If &nbsp; rs.EOF &nbsp; = &nbsp; True &nbsp; Then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit &nbsp; Sub &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End &nbsp; If &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; While &nbsp; Not &nbsp; rs.EOF &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Con.Execute &nbsp; "Insert &nbsp; Into &nbsp; TableName(Name)Values('" &nbsp; &amp; &nbsp; rs(0) &nbsp; &amp; &nbsp; "')" &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rs.MoveNext &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Wend &nbsp; <br>&nbsp; rs.Close &nbsp; <br>&nbsp; cn.Close &nbsp; <br>&nbsp; Con.Close &nbsp; <br>&nbsp; Set &nbsp; rs &nbsp; = &nbsp; Nothing &nbsp; <br>&nbsp; Set &nbsp; cn &nbsp; = &nbsp; Nothing<br><br>And <br><br>Dim &nbsp; cn &nbsp; As &nbsp; New &nbsp; ADODB.Connection &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; cn.Open &nbsp; "Provider=Microsoft.Jet.OLEDB.4.0;Data &nbsp; Source=D:\DB\mdbdata.mdb;Persist &nbsp; Security &nbsp; Info=False" &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; cn.Execute &nbsp; "Insert &nbsp; Into &nbsp; yourTable &nbsp; Select &nbsp; * &nbsp; From &nbsp; [Sheet1$] &nbsp; In &nbsp; ""c:\documents\xldata.xls"" &nbsp; ""EXCEL &nbsp; 5.0;"""&nbsp;&nbsp; <br><br>AND<br><br>Private &nbsp; Sub &nbsp; guiden_Click() &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim &nbsp; tempxlApp &nbsp; As &nbsp; New &nbsp; Excel.Application &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim &nbsp; tempxlWorkbook &nbsp; As &nbsp; New &nbsp; Excel.Workbook &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim &nbsp; tempxlSheet &nbsp; As &nbsp; New &nbsp; Excel.Worksheet &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim &nbsp; strXlsName &nbsp; As &nbsp; String &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'Excel &nbsp; 文件名 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim &nbsp; strSheet &nbsp; As &nbsp; String &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '表名 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim &nbsp; strPcode &nbsp; As &nbsp; String &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '产品编号 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim &nbsp; strTmp &nbsp; As &nbsp; String &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim &nbsp; rsViewP &nbsp; As &nbsp; ADODB.Recordset &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim &nbsp; n &nbsp; As &nbsp; Integer &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '行数 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim &nbsp; i &nbsp; As &nbsp; Integer &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim &nbsp; iNum &nbsp; As &nbsp; Single &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '数量 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Dim &nbsp; iCai &nbsp; As &nbsp; Single &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '材数 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; On &nbsp; Error &nbsp; Resume &nbsp; Next &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cdlInPut.CancelError &nbsp; = &nbsp; True &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'cdlInPut为CommonDialog控件 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '属性DialogTitle是要弹出的对话框的标题 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cdlInPut.DialogTitle &nbsp; = &nbsp; "选择 &nbsp; Microsoft &nbsp; Excel &nbsp; 文件" &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '缺省的文件名为空 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cdlInPut.FileName &nbsp; = &nbsp; "FileName" &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cdlInPut.Filter &nbsp; = &nbsp; "Excel &nbsp; 文件 &nbsp; (*.xls)|*.xls" &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'Flags属性的用法依据不同的对话框而变 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cdlInPut.Flags &nbsp; = &nbsp; cdlOFNHideReadOnly &nbsp; + &nbsp; cdlOFNFileMustExist &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cdlInPut.ShowOpen &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If &nbsp; Err &nbsp; = &nbsp; cdlCancel &nbsp; Then &nbsp; Exit &nbsp; Sub &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strPicName &nbsp; = &nbsp; cdlInPut.FileName &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strSheet &nbsp; = &nbsp; Trim(InputBox("请指定所打开的Excel文件中的一个工作表：", &nbsp; "指定工作表")) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If &nbsp; strSheet &nbsp; = &nbsp; "" &nbsp; Then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MsgBox &nbsp; ("你必须指定一个工作表！"), &nbsp; vbOKOnly &nbsp; + &nbsp; vbExclamation, &nbsp; "提醒！" &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit &nbsp; Sub &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End &nbsp; If &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; n &nbsp; = &nbsp; InputBox("输入需导入行数：", &nbsp; "行数", &nbsp; 114) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prgInput.Visible &nbsp; = &nbsp; True &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 'prgInput为进程条控件 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prgInput.Max &nbsp; = &nbsp; n &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '打开Excel &nbsp; 文件 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set &nbsp; tempxlWorkbook &nbsp; = &nbsp; tempxlApp.Workbooks.Open(strPicName) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tempxlApp.DisplayAlerts &nbsp; = &nbsp; False &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set &nbsp; tempxlSheet &nbsp; = &nbsp; tempxlWorkbook.Worksheets(strSheet) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tempxlSheet.Select &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prgInput.Value &nbsp; = &nbsp; 1 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '把Excel表格中的数据导入表EachDay &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; For &nbsp; i &nbsp; = &nbsp; 4 &nbsp; To &nbsp; n &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strPcode &nbsp; = &nbsp; tempxlSheet.Cells(i, &nbsp; 5) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iNum &nbsp; = &nbsp; tempxlSheet.Cells(i, &nbsp; 17) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If &nbsp; strPcode &nbsp; &lt;&gt; &nbsp; "" &nbsp; And &nbsp; iNum &nbsp; &lt;&gt; &nbsp; 0 &nbsp; Then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strTmp &nbsp; = &nbsp; "select &nbsp; * &nbsp; from &nbsp; Inventory &nbsp; where &nbsp; cInvCode &nbsp; ='" &nbsp; &amp; &nbsp; strPcode &nbsp; &amp; &nbsp; "'" &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set &nbsp; rsViewP &nbsp; = &nbsp; New &nbsp; ADODB.Recordset &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rsViewP.Open &nbsp; strTmp, &nbsp; , &nbsp; adOpenKeyset, &nbsp; adLockOptimistic &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iCai &nbsp; = &nbsp; rsViewP!iCai &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; If &nbsp; rsViewP.RecordCount &nbsp; &gt; &nbsp; 0 &nbsp; Then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '把记录添加到EachDay表中 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; strTmp &nbsp; = &nbsp; "Insert &nbsp; into &nbsp; EachDay &nbsp; (cInvCode,iCount,iRent,dOutDay,cDCCode) &nbsp; VALUES('" &nbsp; &amp; &nbsp; strPcode &nbsp; &amp; &nbsp; "'," &nbsp; &amp; &nbsp; iNum &nbsp; &amp; &nbsp; "," &nbsp; &amp; &nbsp; iNum &nbsp; * &nbsp; iCai &nbsp; &amp; &nbsp; ",#" &nbsp; &amp; &nbsp; rqCH.Value &nbsp; &amp; &nbsp; "#,'" &nbsp; &amp; &nbsp; dcbNetNode.BoundText &nbsp; &amp; &nbsp; "')" &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmSe.CommandText &nbsp; = &nbsp; strTmp &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmSe.Execute &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MsgBox &nbsp; ("此产品不存在！编号：" &nbsp; &amp; &nbsp; strPcode), &nbsp; vbOKOnly &nbsp; + &nbsp; vbExclamation, &nbsp; "提醒！" &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End &nbsp; If &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; rsViewP.Close &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set &nbsp; rsViewP &nbsp; = &nbsp; Nothing &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End &nbsp; If &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prgInput.Value &nbsp; = &nbsp; i &nbsp; - &nbsp; 2 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Next &nbsp; i &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '释放对象,关闭excel &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set &nbsp; tempxlSheet &nbsp; = &nbsp; Nothing &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set &nbsp; tempxlWorkbook &nbsp; = &nbsp; Nothing &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tempxlApp.Quit &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Set &nbsp; tempxlApp &nbsp; = &nbsp; Nothing &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prgInput.Value &nbsp; = &nbsp; n &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prgInput.Visible &nbsp; = &nbsp; False &nbsp; <br>&nbsp; End &nbsp; Sub&nbsp;&nbsp; <br>
<img src ="http://www.blogjava.net/Daniel2005/aggbug/125306.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Daniel2005/" target="_blank">泌鲁沙夫</a> 2007-06-20 12:04 <a href="http://www.blogjava.net/Daniel2005/articles/125306.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>MSSQLServer查询分页 </title><link>http://www.blogjava.net/Daniel2005/articles/120798.html</link><dc:creator>泌鲁沙夫</dc:creator><author>泌鲁沙夫</author><pubDate>Wed, 30 May 2007 01:19:00 GMT</pubDate><guid>http://www.blogjava.net/Daniel2005/articles/120798.html</guid><wfw:comment>http://www.blogjava.net/Daniel2005/comments/120798.html</wfw:comment><comments>http://www.blogjava.net/Daniel2005/articles/120798.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Daniel2005/comments/commentRss/120798.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Daniel2005/services/trackbacks/120798.html</trackback:ping><description><![CDATA[<p>select top 10 * from yc_module where (block_id not in (select top 0 block_id from yc_module order by block_id)) order by block_id;<br></p>
<p>&nbsp;</p>
<p>分页方案一：(利用Not In和SELECT TOP分页)<br>语句形式：<br>SELECT TOP 10 *<br>FROM TestTable<br>WHERE (ID NOT IN<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (SELECT TOP 20 id<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FROM TestTable<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ORDER BY id))<br>ORDER BY ID</p>
<p><br>SELECT TOP 页大小 *<br>FROM TestTable<br>WHERE (ID NOT IN<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (SELECT TOP 页大小*页数 id<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FROM 表<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ORDER BY id))<br>ORDER BY ID</p>
<p>-------------------------------------</p>
<p>分页方案二：(利用ID大于多少和SELECT TOP分页）<br>语句形式：<br>SELECT TOP 10 *<br>FROM TestTable<br>WHERE (ID &gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (SELECT MAX(id)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FROM (SELECT TOP 20 id<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FROM TestTable<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ORDER BY id) AS T))<br>ORDER BY ID</p>
<p><br>SELECT TOP 页大小 *<br>FROM TestTable<br>WHERE (ID &gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (SELECT MAX(id)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FROM (SELECT TOP 页大小*页数 id<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FROM 表<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ORDER BY id) AS T))<br>ORDER BY ID</p>
<p><br>-------------------------------------</p>
<p>分页方案三：(利用SQL的游标存储过程分页)<br>create&nbsp; procedure XiaoZhengGe<br>@sqlstr nvarchar(4000), --查询字符串<br>@currentpage int,&nbsp;--第N页<br>@pagesize int&nbsp;--每页行数<br>as<br>set nocount on<br>declare @P1 int,&nbsp;--P1是游标的id<br>&nbsp;@rowcount int<br>exec sp_cursoropen @P1 output,@sqlstr,@scrollopt=1,@ccopt=1,@rowcount=@rowcount output<br>select ceiling(<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#49;&#46;&#48;&#42;&#64;&#114;&#111;&#119;&#99;&#111;&#117;&#110;&#116;&#47;&#64;&#112;&#97;&#103;&#101;&#115;&#105;&#122;&#101;"><u><font color=#0000ff>1.0*@rowcount/@pagesize</font></u></a>) as 总页数--,@rowcount as 总行数,@currentpage as 当前页&nbsp;<br>set @currentpage=(@currentpage-1)*@pagesize+1<br>exec sp_cursorfetch @P1,16,@currentpage,@pagesize <br>exec sp_cursorclose @P1<br>set nocount off</p>
<p>其它的方案：如果没有主键，可以用临时表，也可以用方案三做，但是效率会低。<br>建议优化的时候，加上主键和索引，查询效率会提高。</p>
<p>通过SQL 查询分析器，显示比较：我的结论是:<br>分页方案二：(利用ID大于多少和SELECT TOP分页）效率最高，需要拼接SQL语句<br>分页方案一：(利用Not In和SELECT TOP分页)&nbsp;&nbsp; 效率次之，需要拼接SQL语句<br>分页方案三：(利用SQL的游标存储过程分页)&nbsp;&nbsp;&nbsp; 效率最差，但是最为通用</p>
<p>在实际情况中，要具体分析。</p>
<img src ="http://www.blogjava.net/Daniel2005/aggbug/120798.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Daniel2005/" target="_blank">泌鲁沙夫</a> 2007-05-30 09:19 <a href="http://www.blogjava.net/Daniel2005/articles/120798.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如何避免被破解!</title><link>http://www.blogjava.net/Daniel2005/articles/111351.html</link><dc:creator>泌鲁沙夫</dc:creator><author>泌鲁沙夫</author><pubDate>Tue, 17 Apr 2007 09:04:00 GMT</pubDate><guid>http://www.blogjava.net/Daniel2005/articles/111351.html</guid><wfw:comment>http://www.blogjava.net/Daniel2005/comments/111351.html</wfw:comment><comments>http://www.blogjava.net/Daniel2005/articles/111351.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Daniel2005/comments/commentRss/111351.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Daniel2005/services/trackbacks/111351.html</trackback:ping><description><![CDATA[&nbsp;btw, If you RUN IIS 6.0, just disable access to root directory using &amp;quote;..\&amp;quote; and also, disable &amp;quote;Detailed Error Message&amp;quote; and replace it with &amp;quote;Sorry, and error has occured&amp;quote; this way, there is no way for the attempting hacker to get any info back. Also in your ASP code or ASP.NET either use stored procedures, or make addition check statements to look at your Request.QueryString(&amp;quote;&amp;quote;) or Request.Form(&amp;quote;&amp;quote;)... like.. do a instr(stringname,&amp;quote;;&amp;quote;) test and see if &amp;quote;;&amp;quote; is found, if so throw exception. because if you enter data into a vulnerable form this will happen: <br>Lets say you input &amp;quote;test' ; &lt;any SQL Command&gt;;&amp;quote; into the form, then for the following SQL Query <br>SQLString = &amp;quote;Select * From Table1 where Username='&amp;quote; &amp; userName &amp; &amp;quote;'&amp;quote;... <br>It would look like : <br>Select * From Table1 where Username='test'; &lt;any SQL Command&gt;; <br>Which would then execute whatever comes after. <br><br>And you should test for other similar things, such as comamnds to Delete records and so forth. :) 
<img src ="http://www.blogjava.net/Daniel2005/aggbug/111351.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Daniel2005/" target="_blank">泌鲁沙夫</a> 2007-04-17 17:04 <a href="http://www.blogjava.net/Daniel2005/articles/111351.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>AJAX+asp.net 1.0不刷新页技术！</title><link>http://www.blogjava.net/Daniel2005/articles/89823.html</link><dc:creator>泌鲁沙夫</dc:creator><author>泌鲁沙夫</author><pubDate>Mon, 25 Dec 2006 01:46:00 GMT</pubDate><guid>http://www.blogjava.net/Daniel2005/articles/89823.html</guid><wfw:comment>http://www.blogjava.net/Daniel2005/comments/89823.html</wfw:comment><comments>http://www.blogjava.net/Daniel2005/articles/89823.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Daniel2005/comments/commentRss/89823.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Daniel2005/services/trackbacks/89823.html</trackback:ping><description><![CDATA[
		<p>已经好长时间没有写日志了！前些日子在网上一直找asp.net 1.0不刷新页技术！我总结了一下。给出了一个例子！<br /><font color="#ff0000"><strong>First step: Create a new page name is AutoComplete.</strong></font><br /><br />&lt;%@ Page Language="vb" AutoEventWireup="false" Codebehind="AutoComplete.aspx.vb" Inherits="VB_AJAXTEST.VB_AJAXTEST.AutoComplete"%&gt;<br />&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;<br />&lt;HTML&gt;<br /> &lt;HEAD&gt;<br />  &lt;title&gt;AutoComplete&lt;/title&gt;<br />  &lt;meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"&gt;<br />  &lt;meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"&gt;<br />  &lt;meta name="vs_defaultClientScript" content="JavaScript"&gt;<br />  &lt;meta name="vs_targetSchema" content="<a href="http://schemas.microsoft.com/intellisense/ie5">http://schemas.microsoft.com/intellisense/ie5</a>"&gt;<br />  &lt;script language="javascript" src="lookup.js"&gt;&lt;/script&gt;<br />  &lt;script language="jscript"&gt;<br />  <br />  mainLoop = function()<br />  {<br />   val = escape(queryField.value);    <br />   if (lastVal != val)<br />   {    <br />    var response = VB_AJAXTEST.VB_AJAXTEST.AutoComplete.GetSearchItems(val);<br />    showQueryDiv(response.value);<br />    lastVal = val;<br />   }    <br />   setTimeout('mainLoop()', 100);<br />   return true;<br />  }<br />  &lt;/script&gt;<br /> &lt;/HEAD&gt;<br /> &lt;body onload="javascript:InitQueryCode('search')"&gt;<br />  &lt;form id="Form1" method="post" runat="server"&gt;<br />   &lt;asp:Label id="Label1" runat="server" Font-Names="黑体,Arial Black" Font-Bold="True" Font-Size="X-Large"&gt;基于AJAX的自动完成功能&lt;/asp:Label&gt;<br />   &lt;hr&gt;<br />   &lt;asp:Label id="Label2" runat="server"&gt;请输入员工姓名：&lt;/asp:Label&gt;<br />   &lt;input name="search" type="text" id="search" autocomplete="off" runat="server"&gt;<br />   &lt;asp:Button id="btnSearch" runat="server" Text="查看"&gt;&lt;/asp:Button&gt;<br />   &lt;br&gt;<br />   &lt;asp:DataList id="dlEmployee" runat="server" BorderColor="#DEDFDE" BorderStyle="None" ForeColor="Black"<br />    BackColor="White" CellPadding="4" GridLines="Vertical" BorderWidth="1px"&gt;<br />    &lt;SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#CE5D5A"&gt;&lt;/SelectedItemStyle&gt;<br />    &lt;AlternatingItemStyle BackColor="White"&gt;&lt;/AlternatingItemStyle&gt;<br />    &lt;ItemStyle BackColor="#F7F7DE"&gt;&lt;/ItemStyle&gt;<br />    &lt;ItemTemplate&gt;<br />     &lt;table cellSpacing="1" cellPadding="1" border="0"&gt;<br />      &lt;tr&gt;<br />       &lt;td&gt;员工编号：&lt;/td&gt;<br />       &lt;td&gt;&lt;%# DataBinder.Eval(Container, "DataItem.emp_id") %&gt;&lt;/td&gt;<br />      &lt;/tr&gt;<br />      &lt;tr&gt;<br />       &lt;td&gt;姓名：&lt;/td&gt;<br />       &lt;td&gt;&lt;%# DataBinder.Eval(Container, "DataItem.fname") %&gt;&amp;nbsp;&lt;%# DataBinder.Eval(Container, "DataItem.lname") %&gt;&lt;/td&gt;<br />      &lt;/tr&gt;<br />      &lt;tr&gt;<br />       &lt;td&gt;入司时间：&lt;/td&gt;<br />       &lt;td&gt;&lt;%# DataBinder.Eval(Container, "DataItem.hire_date", "{0:yyyy-MM-dd}") %&gt;&lt;/td&gt;<br />      &lt;/tr&gt;<br />      &lt;tr&gt;<br />       &lt;td&gt;职位：&lt;/td&gt;<br />       &lt;td&gt;&lt;%# DataBinder.Eval(Container, "DataItem.job_desc") %&gt;&lt;/td&gt;<br />      &lt;/tr&gt;<br />     &lt;/table&gt;<br />    &lt;/ItemTemplate&gt;<br />    &lt;FooterStyle BackColor="#CCCC99"&gt;&lt;/FooterStyle&gt;<br />    &lt;HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#6B696B"&gt;&lt;/HeaderStyle&gt;<br />   &lt;/asp:DataList&gt;<br />   &lt;asp:Label id="lblMessage" runat="server" ForeColor="Red"&gt;&lt;/asp:Label&gt;<br />  &lt;/form&gt;<br /> &lt;/body&gt;<br />&lt;/HTML&gt;<br /><br />AutoComplete.aspx.vb<br />Imports System<br />Imports System.Collections<br />Imports System.ComponentModel<br />Imports System.Data<br />Imports System.Drawing<br />Imports System.Web<br />Imports System.Web.SessionState<br />Imports System.Web.UI<br />Imports System.Web.UI.WebControls<br />Imports System.Web.UI.HtmlControls<br />Imports System.Data.SqlClient<br />Imports AjaxPro</p>
		<p>Namespace VB_AJAXTEST</p>
		<p>    Public Class AutoComplete<br />        Inherits System.Web.UI.Page</p>
		<p>        Protected tbSearch As System.Web.UI.WebControls.TextBox<br />        Protected Label2 As System.Web.UI.WebControls.Label<br />        Protected btnSearch As System.Web.UI.WebControls.Button<br />        Protected dlEmployee As System.Web.UI.WebControls.DataList<br />        Protected search As System.Web.UI.HtmlControls.HtmlInputText<br />        Protected lblMessage As System.Web.UI.WebControls.Label<br />        Protected Label1 As System.Web.UI.WebControls.Label</p>
		<p>        Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)<br />            Utility.RegisterTypeForAjax(GetType(AutoComplete))<br />        End Sub</p>
		<p>        &lt;AjaxMethod()&gt; _<br />        Public Function GetSearchItems(ByVal query As String) As ArrayList<br />            Dim items As ArrayList = New ArrayList<br />            Dim myConnectionString As String = "SERVER=192.168.0.244;DATABASE=pubs;uid=sa;pwd=;Connect Timeout=30"<br />            Dim mySelectQuery As String = String.Format("select fname from employee where fname like '{0}%'", query)<br />            Dim myConnection As SqlConnection = New SqlConnection(myConnectionString)<br />            Dim myCommand As SqlCommand = New SqlCommand(mySelectQuery, myConnection)<br />            myConnection.Open()<br />            Dim myReader As SqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)<br />            While myReader.Read<br />                items.Add(myReader.GetString(0))<br />            End While<br />            myReader.Close()<br />            Return items<br />        End Function</p>
		<p>        Protected Overloads Overrides Sub OnInit(ByVal e As EventArgs)<br />            InitializeComponent()<br />            MyBase.OnInit(e)<br />        End Sub</p>
		<p>        Private Sub InitializeComponent()<br />            AddHandler Me.btnSearch.Click, AddressOf Me.btnSearch_Click<br />            AddHandler Me.Load, AddressOf Me.Page_Load<br />        End Sub</p>
		<p>        Private Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs)<br />            BindList()<br />        End Sub</p>
		<p>        Private Sub BindList()<br />            Dim myConnectionString As String = "SERVER=192.168.0.244;DATABASE=pubs;uid=sa;pwd=;Connect Timeout=30"<br />            Dim mySelectQuery As String = String.Format("select a.*,b.job_desc from employee a, jobs b where fname like '{0}%' and a.job_id=b.job_id", search.Value)<br />            Dim myConnection As SqlConnection = New SqlConnection(myConnectionString)<br />            Dim myCommand As SqlCommand = New SqlCommand(mySelectQuery, myConnection)<br />            Dim da As SqlDataAdapter = New SqlDataAdapter(myCommand)<br />            Dim ds As DataSet = New DataSet<br />            Try<br />                myConnection.Open()<br />                da.Fill(ds)<br />                dlEmployee.DataSource = ds.Tables(0).DefaultView<br />                dlEmployee.DataBind()<br />            Catch ex As SqlException<br />                Response.Write(ex.Message)<br />            Finally<br />                myConnection.Close()<br />            End Try<br />            If ds.Tables(0).Rows.Count = 0 Then<br />                lblMessage.Text = "没有您要查找的员工信息！"<br />            Else<br />                lblMessage.Text = ""<br />            End If<br />        End Sub</p>
		<p>    End Class</p>
		<p>End Namespace<br /><br /><font color="#ff66ff"><font color="#ff0000"><strong>Second Step: Create a AjaxTextBox.vb.</strong></font><br /></font>Imports System<br />Imports System.Web.UI<br />Imports System.Web.UI.WebControls<br />Imports System.Web.UI.WebControls.TextBox</p>
		<p>Public Class AjaxTextBox<br />    Inherits System.Web.UI.WebControls.TextBox</p>
		<p>#Region "Private Property"</p>
		<p>    Private scriptFile_value As String = ""<br />    Private callBackFunction_value As String = ""<br />    Private backgroundColor_value As String = "#EEE"<br />    Private highlightColor_value As String = "#CCC"<br />    Private font_value As String = "Verdana"<br />    Private divPadding_value As String = "2px"<br />    Private divBorder_value As String = "1px solid #CCC"</p>
		<p>#End Region</p>
		<p>#Region "Public Property"</p>
		<p>    Public Property ScriptFile() As String<br />        Get<br />            Return scriptFile_value<br />        End Get<br />        Set(ByVal Value As String)<br />            scriptFile_value = Value<br />        End Set<br />    End Property</p>
		<p>    Public Property CallBackFunction() As String<br />        Get<br />            Return callBackFunction_value<br />        End Get<br />        Set(ByVal Value As String)<br />            callBackFunction_value = Value<br />        End Set<br />    End Property</p>
		<p>    Public Property BackgroundColor() As String<br />        Get<br />            Return backgroundColor_value<br />        End Get<br />        Set(ByVal Value As String)<br />            backgroundColor_value = Value<br />        End Set<br />    End Property</p>
		<p>    Public Property HighlightColor() As String<br />        Get<br />            Return highlightColor_value<br />        End Get<br />        Set(ByVal Value As String)<br />            highlightColor_value = Value<br />        End Set<br />    End Property</p>
		<p>    Public Property DivFont() As String<br />        Get<br />            Return font_value<br />        End Get<br />        Set(ByVal Value As String)<br />            font_value = Value<br />        End Set<br />    End Property</p>
		<p>    Public Property DivPadding() As String<br />        Get<br />            Return divPadding_value<br />        End Get<br />        Set(ByVal Value As String)<br />            divPadding_value = Value<br />        End Set<br />    End Property</p>
		<p>    Public Property DivBorder() As String<br />        Get<br />            Return divBorder_value<br />        End Get<br />        Set(ByVal Value As String)<br />            divPadding_value = Value<br />        End Set<br />    End Property</p>
		<p>#End Region</p>
		<p>#Region "Public AjaxTextBox"</p>
		<p>    Public Sub New()<br />        Me.Attributes.Add("AutoComplete", "off")<br />    End Sub</p>
		<p>    Protected Overloads Overrides Sub Render(ByVal writer As HtmlTextWriter)<br />        MyBase.Render(writer)<br />        Page.RegisterStartupScript("LoadScript", "&lt;script language='JavaScript' src='" + ScriptFile + "'&gt;&lt;/script&gt;")<br />        Dim styles As String = String.Format("&lt;script language='JavaScript'&gt;var DIV_BG_COLOR = '{0}';var DIV_HIGHLIGHT_COLOR = '{1}';var DIV_FONT = '{2}';var DIV_PADDING = '{3}';var DIV_BORDER = '{4}';&lt;/script&gt;", BackgroundColor, HighlightColor, DivFont, DivPadding, DivBorder)<br />        Page.RegisterStartupScript("LookupStyles", styles)<br />        Page.RegisterStartupScript("RegisterScript", "&lt;script language='JavaScript'&gt;InitQueryCode('" + Me.ClientID + "')&lt;/script&gt;")<br />        Page.RegisterStartupScript("RegisterCallBack", "&lt;script language='JavaScript'&gt;mainLoop = function() {val = escape(queryField.value);if(lastVal != val){var response = " + CallBackFunction + "(val);showQueryDiv(response.value); lastVal = val;}setTimeout('mainLoop()', 100);return true;};&lt;/script&gt;")<br />    End Sub</p>
		<p>#End Region</p>
		<p>End Class<br /><br /><font color="#ff0000"><strong>Third step: Create a lookup.js</strong></font><br />// 下拉区背景色<br />var DIV_BG_COLOR = "#EEE";<br />// 高亮显示条目颜色<br />var DIV_HIGHLIGHT_COLOR = "#C30";<br />// 字体<br />var DIV_FONT = "Arial";<br />// 下拉区内补丁大小<br />var DIV_PADDING = "2px";<br />// 下拉区边框样式<br />var DIV_BORDER = "1px solid #CCC";</p>
		<p>
				<br />// 文本输入框<br />var queryField;<br />// 下拉区id<br />var divName;<br />// IFrame名称<br />var ifName;<br />// 记录上次选择的值<br />var lastVal = "";<br />// 当前选择的值<br />var val = "";<br />// 显示结果的下拉区<br />var globalDiv;<br />// 下拉区是否设置格式的标记<br />var divFormatted = false;</p>
		<p>/**<br />InitQueryCode函数必须在&lt;body onload&gt;事件的响应函数中调用,其中:<br />queryFieldName为文本框控件的id,<br />hiddenDivName为显示下拉区div的id<br />*/<br />function InitQueryCode (queryFieldName, hiddenDivName)<br />{<br /> // 指定文本输入框的onblur和onkeydown响应函数<br /> queryField = document.getElementById(queryFieldName);<br /> queryField.onblur = hideDiv;<br /> queryField.onkeydown = keypressHandler;</p>
		<p> // 设置queryField的autocomplete属性为"off"<br /> queryField.autocomplete = "off";</p>
		<p> // 如果没有指定hiddenDivName,取默认值"querydiv"<br /> if (hiddenDivName)<br /> {<br />  divName = hiddenDivName;<br /> }<br /> else<br /> {<br />  divName = "querydiv";<br /> }<br /> <br /> // IFrame的name<br /> ifName = "queryiframe";<br /> <br /> // 100ms后调用mainLoop函数<br /> setTimeout("mainLoop()", 100);<br />}</p>
		<p>/**<br />获取下拉区的div,如果没有则创建之<br />*/<br />function getDiv (divID)<br />{<br /> if (!globalDiv)<br /> {<br />  // 如果div在页面中不存在,创建一个新的div<br />  <br />  if (!document.getElementById(divID))<br />  {<br />   var newNode = document.createElement("div");<br />   newNode.setAttribute("id", divID);<br />   document.body.appendChild(newNode);<br />  }</p>
		<p>  // globalDiv设置为div的引用  <br />  globalDiv = document.getElementById(divID);</p>
		<p>  // 计算div左上角的位置  <br />  var x = queryField.offsetLeft;<br />  var y = queryField.offsetTop + queryField.offsetHeight;<br />  var parent = queryField;<br />  while (parent.offsetParent)<br />  {<br />   parent = parent.offsetParent;<br />   x += parent.offsetLeft;<br />   y += parent.offsetTop;<br />  }</p>
		<p>  // 如果没有对div设置格式,则为其设置相应的显示样式  <br />  if (!divFormatted)<br />  {<br />   globalDiv.style.backgroundColor = DIV_BG_COLOR;<br />   globalDiv.style.fontFamily = DIV_FONT;<br />   globalDiv.style.padding = DIV_PADDING;<br />   globalDiv.style.border = DIV_BORDER;<br />   globalDiv.style.width = "100px";<br />   globalDiv.style.fontSize = "90%";</p>
		<p>   globalDiv.style.position = "absolute";<br />   globalDiv.style.left = x + "px";<br />   globalDiv.style.top = y + "px";<br />   globalDiv.style.visibility = "hidden";<br />   globalDiv.style.zIndex = 10000;</p>
		<p>   divFormatted = true;<br />  }<br /> }</p>
		<p> return globalDiv;<br />}</p>
		<p>/**<br />根据返回的结果集显示下拉区<br />*/<br />function showQueryDiv(resultArray)<br />{<br /> // 获取div的引用<br /> var div = getDiv(divName);<br /> <br /> // 如果div中有内容,则删除之<br /> while (div.childNodes.length &gt; 0)<br />  div.removeChild(div.childNodes[0]);</p>
		<p> // 依次添加结果<br /> for (var i = 0; i &lt; resultArray.length; i++)<br /> {<br />  // 每一个结果也是一个div<br />  var result = document.createElement("div");<br />  // 设置结果div的显示样式<br />  result.style.cursor = "pointer";<br />  result.style.padding = "2px 0px 2px 0px";<br />  // 设置为未选中<br />  _unhighlightResult(result);<br />  // 设置鼠标移进、移出等事件响应函数<br />  result.onmousedown = selectResult;<br />  result.onmouseover = highlightResult;<br />  result.onmouseout = unhighlightResult;</p>
		<p>  // 结果的文本是一个span<br />  var result1 = document.createElement("span");<br />  // 设置文本span的显示样式<br />  result1.className = "result1";<br />  result1.style.textAlign = "left";<br />  result1.style.fontWeight = "bold";<br />  result1.innerHTML = resultArray[i];<br />  <br />  // 将span添加为结果div的子节点<br />  result.appendChild(result1);<br />  <br />  // 将结果div添加为下拉区的子节点<br />  div.appendChild(result);<br /> }</p>
		<p> // 如果结果集不为空,则显示,否则不显示<br /> showDiv(resultArray.length &gt; 0);<br />}</p>
		<p>/**<br />用户点击某个结果时,将文本框的内容替换为结果的文本,<br />并隐藏下拉区<br />*/<br />function selectResult()<br />{<br /> _selectResult(this);<br />}</p>
		<p>// 选择一个条目<br />function _selectResult(item)<br />{<br /> var spans = item.getElementsByTagName("span");<br /> if (spans)<br /> {<br />  for (var i = 0; i &lt; spans.length; i++)<br />  {<br />   if (spans[i].className == "result1")<br />   {<br />    queryField.value = spans[i].innerHTML;<br />    lastVal = val = escape(queryField.value);<br />    mainLoop();<br />    queryField.focus();<br />    showDiv(false);<br />    return;<br />   }<br />  }<br /> }<br />}</p>
		<p>/**<br />当鼠标移到某个条目之上时,高亮显示该条目<br />*/<br />function highlightResult()<br />{<br /> _highlightResult(this);<br />}</p>
		<p>function _highlightResult(item)<br />{<br /> item.style.backgroundColor = DIV_HIGHLIGHT_COLOR;<br />}</p>
		<p>/**<br />当鼠标移出某个条目时,正常显示该条目<br />*/<br />function unhighlightResult()<br />{<br /> _unhighlightResult(this);<br />}</p>
		<p>function _unhighlightResult(item)<br />{<br /> item.style.backgroundColor = DIV_BG_COLOR;<br />}</p>
		<p>/**<br />显示/不显示下拉区<br />*/<br />function showDiv (show)<br />{<br /> var div = getDiv(divName);<br /> if (show)<br /> {<br />  div.style.visibility = "visible";<br /> }<br /> else<br /> {<br />  div.style.visibility = "hidden";<br /> }<br /> //adjustiFrame();<br />}</p>
		<p>/**<br />隐藏下拉区<br />*/<br />function hideDiv ()<br />{<br /> showDiv(false);<br />}</p>
		<p>/**<br />调整IFrame的位置,这是为了解决div可能会显示在输入框后面的问题<br />*/<br />function adjustiFrame()<br />{<br /> // 如果没有IFrame,则创建之<br /> if (!document.getElementById(ifName))<br /> {<br />  var newNode = document.createElement("iFrame");<br />  newNode.setAttribute("id", ifName);<br />  newNode.setAttribute("src", "javascript:false;");<br />  newNode.setAttribute("scrolling", "no");<br />  newNode.setAttribute("frameborder", "0");<br />  document.body.appendChild(newNode);<br /> }</p>
		<p> iFrameDiv = document.getElementById(ifName);<br /> var div = getDiv(divName);</p>
		<p> // 调整IFrame的位置与div重合,并在div的下一层  <br /> try<br /> {<br />  iFrameDiv.style.position = "absolute";<br />  iFrameDiv.style.width = div.offsetWidth;<br />  iFrameDiv.style.height = div.offsetHeight;<br />  iFrameDiv.style.top = div.style.top;<br />  iFrameDiv.style.left = div.style.left;<br />  iFrameDiv.style.zIndex = div.style.zIndex - 1;<br />  iFrameDiv.style.visibility = div.style.visibility;<br /> }<br /> catch (e)<br /> {<br /> }<br />}</p>
		<p>/**<br />文本输入框的onkeydown响应函数<br />*/<br />function keypressHandler (evt)<br />{<br /> // 获取对下拉区的引用  <br /> var div = getDiv(divName);<br /> <br /> // 如果下拉区不显示,则什么也不做  <br /> if (div.style.visibility == "hidden")<br /> {<br />  return true;<br /> }</p>
		<p> // 确保evt是一个有效的事件 <br /> if (!evt &amp;&amp; window.event)<br /> {<br />  evt = window.event;<br /> }<br /> var key = evt.keyCode;</p>
		<p> var KEYUP = 38;<br /> var KEYDOWN = 40;<br /> var KEYENTER = 13;<br /> var KEYTAB = 9;<br /> <br /> // 只处理上下键、回车键和Tab键的响应  <br /> if ((key != KEYUP) &amp;&amp; (key != KEYDOWN) &amp;&amp; (key != KEYENTER) &amp;&amp; (key != KEYTAB))<br /> {<br />  return true;<br /> }</p>
		<p> var selNum = getSelectedSpanNum(div);<br /> var selSpan = setSelectedSpan(div, selNum);<br /> <br /> // 如果键入回车和Tab,则选择当前选择条目 <br /> if ((key == KEYENTER) || (key == KEYTAB))<br /> {<br />  if (selSpan)<br />  {<br />   _selectResult(selSpan);<br />  }<br />  evt.cancelBubble = true;<br />  return false;<br /> }<br /> else //如果键入上下键,则上下移动选中条目<br /> {<br />  if (key == KEYUP)<br />  {<br />   selSpan = setSelectedSpan(div, selNum - 1);<br />  }<br />  if (key == KEYDOWN)<br />  {<br />   selSpan = setSelectedSpan(div, selNum + 1);<br />  }<br />  if (selSpan)<br />  {<br />   _highlightResult(selSpan);<br />  }<br /> }</p>
		<p> // 显示下拉区<br /> showDiv(true);<br /> return true;<br />}</p>
		<p>/**<br />获取当前选中的条目的序号<br />*/<br />function getSelectedSpanNum(div)<br />{<br /> var count = -1;<br /> var spans = div.getElementsByTagName("div");<br /> if (spans)<br /> {<br />  for (var i = 0; i &lt; spans.length; i++)<br />  {<br />   count++;<br />   if (spans[i].style.backgroundColor != div.style.backgroundColor)<br />   {<br />    return count;<br />   }<br />  }<br /> }</p>
		<p> return -1;<br />}</p>
		<p>/**<br />选择指定序号的结果条目<br />*/<br />function setSelectedSpan(div, spanNum)<br />{<br /> var count = -1;<br /> var thisSpan;<br /> var spans = div.getElementsByTagName("div");<br /> if (spans)<br /> {<br />  for (var i = 0; i &lt; spans.length; i++)<br />  {<br />   if (++count == spanNum)<br />   {<br />    _highlightResult(spans[i]);<br />    thisSpan = spans[i];<br />   }<br />   else<br />   {<br />    _unhighlightResult(spans[i]);<br />   }<br />  }<br /> }</p>
		<p> return thisSpan;<br />}<br /><br /><font color="#ff0000"><strong>Fourthly: Add httpHandlers request in web.config.<br /></strong></font>  &lt;httpHandlers&gt;<br />   &lt;add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro" /&gt;<br />  &lt;/httpHandlers&gt;<br /><br />Dont' forget download a AjaxPro.dll then add the dll to the project.<br /></p>
<img src ="http://www.blogjava.net/Daniel2005/aggbug/89823.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Daniel2005/" target="_blank">泌鲁沙夫</a> 2006-12-25 09:46 <a href="http://www.blogjava.net/Daniel2005/articles/89823.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQL Server 2000中的数据转换服务 (DTS) http://www.microsoft.com/china/technet/prodtechnol/sql/2000/deploy/dtssql2k.mspx</title><link>http://www.blogjava.net/Daniel2005/articles/83264.html</link><dc:creator>泌鲁沙夫</dc:creator><author>泌鲁沙夫</author><pubDate>Fri, 24 Nov 2006 07:07:00 GMT</pubDate><guid>http://www.blogjava.net/Daniel2005/articles/83264.html</guid><wfw:comment>http://www.blogjava.net/Daniel2005/comments/83264.html</wfw:comment><comments>http://www.blogjava.net/Daniel2005/articles/83264.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Daniel2005/comments/commentRss/83264.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Daniel2005/services/trackbacks/83264.html</trackback:ping><description><![CDATA[
		<h1>SQL Server 2000中的数据转换服务 (DTS)</h1>
		<div class="date">更新日期： 2004年06月15日</div>
		<div class="byline">发布者 Diane Larsen</div>
		<div class="overview">
				<p>Euan Garden, 投稿人</p>
				<p>Microsoft Corporation</p>
				<p>2000 年 9 月</p>
				<p>
						<b>摘要： </b>为了完成数据合并、存档和分析等任务；为了进行应用程序开发；为了进行数据库或服务器升级，数据库管理员经常需要导入、导出以及转换数据。SQL Server 2000 中的数据转换服务（DTS）为此提供了一组图形化工具和可编程对象，能够帮助管理员和开发人员解决从不同来源到单个或多个目标的数据转移问题，包括数据提取、转换以及合并。您可以将任务、工作流操作和限制条件组成 DTS<i>数据包</i>，然后安排定期或在特定事件发生时执行该数据包。本白皮书将介绍 DTS，给出一些能够用于创建 DTS 解决方案的组件和服务，介绍如何使用 DTS Designer 来实施 DTS 解决方案，最后将介绍 DTS 应用程序开发。</p>
		</div>
		<center>
				<img title="" height="6" alt="*" src="http://img.microsoft.com/library/gallery/templates/MNP2.Common/images/3squares.gif" width="30" border="0" />
		</center>
		<div style="HEIGHT: 18px">
		</div>
		<h5 style="PADDING-TOP: 2px">本页内容</h5>
		<table style="MARGIN-TOP: 7px; MARGIN-BOTTOM: 12px" cellspacing="0" cellpadding="0" border="0">
				<tbody>
						<tr valign="top">
								<td>
										<a href="http://www.microsoft.com/china/technet/prodtechnol/sql/2000/deploy/dtssql2k.mspx#ETB">
												<img height="9" alt="DTS 简介" hspace="4" src="http://www.microsoft.com/library/gallery/templates/MNP2.Common/images/arrow_px_down.gif" width="7" vspace="2" border="0" />
										</a>
								</td>
								<td class="onThisPage">
										<a href="http://www.microsoft.com/china/technet/prodtechnol/sql/2000/deploy/dtssql2k.mspx#ETB">DTS 简介</a>
								</td>
						</tr>
						<tr valign="top">
								<td>
										<a href="http://www.microsoft.com/china/technet/prodtechnol/sql/2000/deploy/dtssql2k.mspx#ESD">
												<img height="9" alt="使用 DTS Designer" hspace="4" src="http://www.microsoft.com/library/gallery/templates/MNP2.Common/images/arrow_px_down.gif" width="7" vspace="2" border="0" />
										</a>
								</td>
								<td class="onThisPage">
										<a href="http://www.microsoft.com/china/technet/prodtechnol/sql/2000/deploy/dtssql2k.mspx#ESD">使用 DTS Designer</a>
								</td>
						</tr>
						<tr valign="top">
								<td>
										<a href="http://www.microsoft.com/china/technet/prodtechnol/sql/2000/deploy/dtssql2k.mspx#ECAAE">
												<img height="9" alt="保存 DTS 数据包的选项" hspace="4" src="http://www.microsoft.com/library/gallery/templates/MNP2.Common/images/arrow_px_down.gif" width="7" vspace="2" border="0" />
										</a>
								</td>
								<td class="onThisPage">
										<a href="http://www.microsoft.com/china/technet/prodtechnol/sql/2000/deploy/dtssql2k.mspx#ECAAE">保存 DTS 数据包的选项</a>
								</td>
						</tr>
						<tr valign="top">
								<td>
										<a href="http://www.microsoft.com/china/technet/prodtechnol/sql/2000/deploy/dtssql2k.mspx#ETAAE">
												<img height="9" alt="将 DTS 作为应用程序开发平台" hspace="4" src="http://www.microsoft.com/library/gallery/templates/MNP2.Common/images/arrow_px_down.gif" width="7" vspace="2" border="0" />
										</a>
								</td>
								<td class="onThisPage">
										<a href="http://www.microsoft.com/china/technet/prodtechnol/sql/2000/deploy/dtssql2k.mspx#ETAAE">将 DTS 作为应用程序开发平台</a>
								</td>
						</tr>
				</tbody>
		</table>
		<a name="ETB">
		</a>
		<h2>DTS 简介</h2>
		<p>大部分公司的数据都具有多种存储格式和存储位置。为了支持决策制定、提高系统性能或升级现有系统，经常必须将数据从一个数据存储位置转移到另一个位置。</p>
		<p>Microsoft SQL Server 2000 数据转换服务（DTS）为此提供了一系列的工具，您可以用来从不同来源将数据提取、转换和合并到单个或多个目标。通过使用DTS工具，您可以根据公司的特殊需求创建定制的数据移动解决方案，正如下面这些情形：</p>
		<table cellspacing="0" cellpadding="0" border="0">
				<tbody>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>您已经在早期版本的 SQL Server 或其他平台（例如 Microsoft Access）上部署了一个数据库应用程序。现在，新版本的应用程序需要 SQL Server 2000，而且需要更改数据库架构，并转换部分数据类型。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>为了复制和转换数据，可以构建一个 DTS 解决方案，将数据库对象从原始数据源复制到 SQL Server 2000 数据库中，同时重新设置数据栏并更改数据类型。您可以使用 DTS 工具来运行这个解决方案，或者将这个解决方案嵌入到您的应用程序中。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>您必须将一些关键的 Microsoft Excel 电子表格合并到 SQL Server 数据库中。很多部门在每月底创建电子表格，但是没有设置日程安排来完成所有的电子表格。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>为了合并电子表格数据，您可以构建一个 DTS 解决方案，使其在消息被发送到消息队列时执行。这个消息将触发 DTS，使其从电子表格中提取数据，执行各种定义的转换，然后将数据装载到 SQL Server 数据库中。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>您的数据仓库中保存了有关业务操作的历史数据，您要使用 Microsoft SQL Server 2000 分析服务来汇总这些数据。这个数据仓库需要每天夜间从联机事务处理（OLTP）数据库进行更新。而您的 OLTP 系统一天 24 小时都在使用中，其性能十分关键。</p>
										<p>您可以构建一个 DTS 解决方案，使用文件传输协议（FTP）将数据文件移动到本地驱动器中，将数据装载到事实表中，然后使用分析服务对数据进行统计。您可以安排这个 DTS 解决方案每天夜间执行，也可以使用新的 DTS 日志选项来跟踪这个过程所用的时间，使您能够分析性能随时间的变化。</p>
								</td>
						</tr>
				</tbody>
		</table>
		<h3>DTS 是什么?</h3>
		<p>DTS 是一组数据转换工具，您可以用来在一个或多个数据源（例如 Microsoft SQL Server、 Microsoft Excel 或 Microsoft Access）之间进行不同类型数据的导入、导出和转换。其中的连通性通过数据访问的开放式标准－OLE DB－来提供。ODBC（开放式数据库连接）数据源由 OLE DB Provider for ODBC 来支持。</p>
		<p>您可以将 DTS 解决方案创建为一个或多个<i>数据包</i>。每个数据包中可以包含一组有序的任务，定义所要执行的工作，也可以包含数据和对象的转换、定义任务执行的工作流限制以及数据源和目标的连接等。DTS 数据包也提供记录数据包执行细节、控制事务以及处理全局变量等服务。</p>
		<p>下列工具可以用于创建和执行 DTS 数据包：</p>
		<table cellspacing="0" cellpadding="0" border="0">
				<tbody>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>导入/导出向导（Import/Export Wizard）用于构建相对简单的 DTS 数据包，支持数据迁移和简单转换。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>DTS Designer 图形化地实施 DTS 对象模型，允许您创建具有大量功能的 DTS 数据包。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>
												<b>DTSRun</b>是一个命令提示符实用程序，用来执行已有的 DTS 数据包。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>DTSRunUI 是<b>DTSRun</b>的图形化界面, 也允许传递全局变量和生成命令行。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>SQLAgent 不是一个 DTS 应用程序；但是 DTS 可以用它来安排数据包的执行。</p>
								</td>
						</tr>
				</tbody>
		</table>
		<p>您也可以使用 DTS 对象模型通过编程创建和运行数据包，构建定制任务以及构建定制转换。</p>
		<h3>DTS 中的新内容?</h3>
		<p>Microsoft SQL Server 2000 引入了许多 DTS 增强和新特性：</p>
		<table cellspacing="0" cellpadding="0" border="0">
				<tbody>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>新的 DTS 任务包括 FTP 任务、执行数据包任务、动态属性任务以及消息队列任务。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>增强的日志功能记录了每个数据包执行的信息，允许您拥有完整的执行历史，并能查看任务中每个步骤的信息。您可以生成异常文件，包含可能由于错误而没有执行的数据行。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>您可以将 DTS 数据包保存为 Microsoft Visual Basic 文件。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>新的多段数据泵允许高级用户在不同阶段定制数据转换操作。同时，也可以使用全局变量作为查询的输入参数。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>您可以在 DTS 转换任务和执行 SQL 任务中使用参数化的源查询。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>您可以使用执行数据包任务，动态地将全局变量的取值从父数据包分配到子数据包。</p>
								</td>
						</tr>
				</tbody>
		</table>
		<div style="MARGIN-TOP: 3px; MARGIN-BOTTOM: 10px">
				<a href="http://www.microsoft.com/china/technet/prodtechnol/sql/2000/deploy/dtssql2k.mspx#top">
						<img height="9" alt="返回页首" src="http://www.microsoft.com/library/gallery/templates/MNP2.Common/images/arrow_px_up.gif" width="7" border="0" />
				</a>
				<a class="topOfPage" href="http://www.microsoft.com/china/technet/prodtechnol/sql/2000/deploy/dtssql2k.mspx#top">返回页首</a>
		</div>
		<a name="ESD">
		</a>
		<h2>使用 DTS Designer</h2>
		<p>DTS Designer 图形化地实施 DTS 对象模型，允许您图形化地创建 DTS 数据包。您可以使用 DTS Designer 来：</p>
		<table cellspacing="0" cellpadding="0" border="0">
				<tbody>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>创建包含一个或多个步骤的简单数据包。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>创建包含复杂工作流的数据包，这些工作流中可包含使用有条件逻辑的多步操作、事件驱动的代码或多个数据源的连接。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>编辑已有的数据包。</p>
								</td>
						</tr>
				</tbody>
		</table>
		<p>DTS Designer 界面由工作区域、工具栏和菜单组成。其中工作区域用于构建数据包，工具栏包含有数据包元素，您可以将它们拖动到设计页中，菜单中包含有工作流和数据包管理命令。</p>
		<div style="WIDTH: 335px">
				<img height="219" alt="图1：DTS Designer界面" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql01.gif" width="335" border="0" />
				<br />
				<p class="figureCaption">
						<b>图1：DTS Designer 界面</b>
						<br />
						<a href="http://www.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql01_BIG.gif" target="_blank">查看大图。</a>
				</p>
				<div class="figureRule">
				</div>
		</div>
		<p>在 DTS Designer 中，您可以将连接和任务拖动到设计页中，并指定工作流执行的顺序，从而轻松地创建功能强大的 DTS 数据包。下面的内容将定义任务、工作流、连接和转换，并介绍如何使用 DTS Designer 轻松地实施 DTS 解决方案。</p>
		<h3>任务：定义数据包中的步骤</h3>
		<p>DTS 数据包中通常包含一个或多个步骤。每个任务定义了一个可能在数据包执行过程中执行的工作项目。您可以使用任务来：</p>
		<table cellspacing="0" cellpadding="0" border="0">
				<tbody>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>转换数据</p>
										<table class="dataTable" id="ERE" cellspacing="0" cellpadding="0" width="90%">
												<thead>
												</thead>
												<tbody>
														<tr class="record" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="18" alt="dtssql02" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql02.gif" width="21" border="0" />
																		</p>
																</td>
																<td>
																		<p class="lastInCell">转换数据任务</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">用来将数据从来源移动到目标，可以选择在数据上应用数据栏转换。</p>
																</td>
														</tr>
														<tr class="evenRecord" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="19" alt="dtssql03" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql03.gif" width="16" border="0" />
																		</p>
																</td>
																<td>
																		<p class="lastInCell">数据驱动的查询任务</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">用来对数据执行基于 Transact-SQL 的灵活操作，包括存储过程以及 INSERT、UPDATE 或 DELETE 声明。</p>
																</td>
														</tr>
														<tr class="record" valign="top">
																<td>
																		<p class="lastInCell">?</p>
																</td>
																<td>
																		<p class="lastInCell">平行数据泵任务 (1)</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">仅可用于编程，平行数据泵任务执行与转换数据和数据驱动的查询任务相同的功能，但是支持 OLE DB 2.5 及更新版本所定义的 “章节式” 数据行集。</p>
																</td>
														</tr>
												</tbody>
										</table>
										<div class="dataTableBottomMargin">
										</div>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>复制和管理数据</p>
										<table class="dataTable" id="E2F" cellspacing="0" cellpadding="0" width="90%">
												<thead>
												</thead>
												<tbody>
														<tr class="record" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="18" alt="dtssql04" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql04.gif" width="19" border="0" />
																		</p>
																</td>
																<td>
																		<p class="lastInCell">批量插入任务</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">用于快速地将批量数据装载到 SQL Server 表或视图中。</p>
																</td>
														</tr>
														<tr class="evenRecord" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="23" alt="dtssql05" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql05.gif" width="19" border="0" />
																		</p>
																</td>
																<td>
																		<p class="lastInCell">Execute SQL 任务</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">用于在数据包执行过程中运行 SQL 语句。Execute SQL 任务也可以保存查询的结果数据。</p>
																</td>
														</tr>
														<tr class="record" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="20" alt="dtssql06" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql06.gif" width="18" border="0" />
																		</p>
																</td>
																<td>
																		<p class="lastInCell">Copy SQL Server Objects 任务</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">用来将 SQL Server 对象从一个 SQL Server 安装或实例中复制到另一个中。您可以复制数据和表等对象，也可以复制视图和存储过程等对象定义。</p>
																</td>
														</tr>
														<tr class="evenRecord" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="18" alt="dtssql07" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql07.gif" width="18" border="0" />
																		</p>
																</td>
																<td>
																		<p class="lastInCell">Transfer Database 任务(1)</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">用来将 SQL Server 数据库从一个 SQL Server 7.0 或 SQL Server 2000 实例移动或复制到 SQL Server 2000 实例中。</p>
																</td>
														</tr>
														<tr class="record" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="18" alt="dtssql08" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql08.gif" width="19" border="0" />
																		</p>
																</td>
																<td>
																		<p class="lastInCell">Transfer Error Messages 任务(1)</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">用于将用户指定的错误消息从 SQL Server 7.0 或 SQL Server 2000 实例复制到 SQL Server 2000 实例，这些错误消息是由<b>sp_addmessage</b>系统存储过程所生成的。</p>
																</td>
														</tr>
														<tr class="evenRecord" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="19" alt="dtssql09" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql09.gif" width="19" border="0" />
																		</p>
																</td>
																<td>
																		<p class="lastInCell">Transfer Logins 任务(1)</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">用来将帐号从 SQL Server 7.0 或 SQL Server 2000 实例复制到 SQL Server 2000 实例。</p>
																</td>
														</tr>
														<tr class="record" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="17" alt="dtssql10" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql10.gif" width="19" border="0" />
																		</p>
																</td>
																<td>
																		<p class="lastInCell">Transfer Jobs 任务(1)</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">用来将作业从 SQL Server 7.0 或 SQL Server 2000 实例复制到 SQL Server 2000 实例。</p>
																</td>
														</tr>
														<tr class="evenRecord" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="19" alt="dtssql11" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql11.gif" width="19" border="0" />
																		</p>
																</td>
																<td>
																		<p class="lastInCell">Transfer Master Stored Procedures 任务(1)</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">用来将存储过程从 SQL Server 7.0 或 SQL Server 2000 实例中的<b>master</b>数据库复制到 SQL Server 2000 实例的 <b>master</b>数据库。</p>
																</td>
														</tr>
												</tbody>
										</table>
										<div class="dataTableBottomMargin">
										</div>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>从数据包中将任务作为作业运行</p>
										<table class="dataTable" id="EGBAC" cellspacing="0" cellpadding="0" width="90%">
												<thead>
												</thead>
												<tbody>
														<tr class="record" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="17" alt="dtssql12" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql12.gif" width="19" border="0" />
																		</p>
																</td>
																<td>
																		<p class="lastInCell">ActiveX Script 任务</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">用来编写代码，执行其他 DTS 任务中没有的功能。</p>
																</td>
														</tr>
														<tr class="evenRecord" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="18" alt="dtssql13" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql13.gif" width="18" border="0" />
																		</p>
																</td>
																<td>
																		<p class="lastInCell">Dynamic Properties 任务(1)</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">用于在数据包运行时从 DTS 数据包外的来源处获得数值，并将这些值分配给选定的数据包属性。</p>
																</td>
														</tr>
														<tr class="record" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="18" alt="dtssql14" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql14.gif" width="21" border="0" />
																		</p>
																</td>
																<td>
																		<p class="lastInCell">Execute Package 任务(1)</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">用于从数据包中运行其他 DTS 数据包。</p>
																</td>
														</tr>
														<tr class="evenRecord" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="20" alt="dtssql15" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql15.gif" width="19" border="0" />
																		</p>
																</td>
																<td>
																		<p class="lastInCell">Execute Process 任务</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">用于运行可执行程序或批处理文件。</p>
																</td>
														</tr>
														<tr class="record" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="19" alt="dtssql16" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql16.gif" width="21" border="0" />
																		</p>
																</td>
																<td>
																		<p class="lastInCell">FTP 任务 (1)</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">用来从远程服务器或 Internet 位置下载数据文件。</p>
																</td>
														</tr>
														<tr class="evenRecord" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="18" alt="dtssql17" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql17.gif" width="18" border="0" />
																		</p>
																</td>
																<td>
																		<p class="lastInCell">Message Queue 任务(1)</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">用来从 Microsoft 消息队列发送和接受消息。</p>
																</td>
														</tr>
														<tr class="record" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="17" alt="dtssql18" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql18.gif" width="20" border="0" />
																		</p>
																</td>
																<td>
																		<p class="lastInCell">Send Mail 任务</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">用来发送电子邮件。</p>
																</td>
														</tr>
														<tr class="evenRecord" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="19" alt="dtssql19" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql19.gif" width="18" border="0" />
																		</p>
																</td>
																<td>
																		<p class="lastInCell">Analysis Services Processing 任务 (2)</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">用于处理一个或多个 SQL Server 2000 分析服务中所定义的对象。</p>
																</td>
														</tr>
														<tr class="record" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="20" alt="dtssql20" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql20.gif" width="19" border="0" />
																		</p>
																</td>
																<td>
																		<p class="lastInCell">Data Mining 任务 (1,2)</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">用于从 SQL Server 2000 分析服务所定义的数据挖掘模型对象中创建一个预测查询和输出表。</p>
																</td>
														</tr>
												</tbody>
										</table>
										<div class="dataTableBottomMargin">
										</div>
								</td>
						</tr>
				</tbody>
		</table>
		<p>1 SQL Server 2000中新增。</p>
		<p>2 仅适用于已安装 SQL Server 2000 分析服务的情形。</p>
		<p>您可以程序化地创建定制任务，然后使用 Register Custom Task（注册定制任务）命令将它们集成到 DTS Designer 中。</p>
		<p>为了说明这些任务的使用，在这里我们给出了一个包含两个任务的简单 DTS 数据包： Microsoft ActiveX Script 任务和 Send Mail 任务：</p>
		<div style="WIDTH: 242px">
				<img height="54" alt="图2：具有两个任务的DTS数据包" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql21.gif" width="242" border="0" />
				<br />
				<p class="figureCaption">
						<b>图2：具有两个任务的 DTS 数据包</b>
				</p>
				<div class="figureRule">
				</div>
		</div>
		<p>ActiveX Script 任务可以驻留任何 ActiveX 脚本引擎，包括 Microsoft Visual Basic Scripting Edition (VBScript)、Microsoft JScript 或者 ActiveState ActivePerl（您可以从<a href="http://www.activestate.com/">http://www.activestate.com [英文]</a>下载）。 Send Mail 任务可以发送消息，指出该数据包已经运行。请注意，这些任务是没有顺序的。在执行数据包时，ActiveX Script 任务和 Send Mail 任务同时运行。</p>
		<h3>工作流：设置任务优先级</h3>
		<p>当您在定义一组任务时，通常任务的执行是应该有一定顺序的。如果这些任务拥有一定的顺序，那么每个任务将称为一个过程中的一个步骤。在 DTS Designer 中，您可以在 DTS Designer 设计页中对任务进行操作，使用优先级限制来控制任务执行的顺序。</p>
		<p>优先级限制将数据包中的任务依次链接起来。下表给出了您可以在 DTS 中使用的优先级限制的类型。</p>
		<table class="dataTable" id="EBFAC" cellspacing="0" cellpadding="0" width="90%">
				<thead>
						<tr class="stdHeader" valign="top">
								<td id="colEEFAC" width="27%">优先级限制</td>
								<td id="colEIFAC" style="BORDER-RIGHT: #cccccc 1px solid" width="73%">说明</td>
						</tr>
				</thead>
				<tbody>
						<tr class="record" valign="top">
								<td>
										<p class="lastInCell">
												<img height="13" alt="dtssql22" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql22.gif" width="97" border="0" />
												<br />
												<b>On Completion（完成后）</b>
												<br />(蓝色箭头)</p>
								</td>
								<td style="BORDER-RIGHT: #cccccc 1px solid">
										<p class="lastInCell">如果您希望任务 2 处于等待状态，直至任务 1 完成（无论结果如何），那么就使用 On Completion 优先级限制将任务 1 链接到任务 2。</p>
								</td>
						</tr>
						<tr class="evenRecord" valign="top">
								<td>
										<p class="lastInCell">
												<img height="14" alt="dtssql23" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql23.gif" width="97" border="0" />
												<br />
												<b>On Success（成功后）</b>
												<br />(绿色箭头)</p>
								</td>
								<td style="BORDER-RIGHT: #cccccc 1px solid">
										<p class="lastInCell">如果您希望任务 2 处于等待状态，直至任务 1 成功完成，那么就使用 On Success 优先级限制将任务 1 链接到任务 2。</p>
								</td>
						</tr>
						<tr class="record" valign="top">
								<td>
										<p class="lastInCell">
												<img height="12" alt="dtssql24" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql24.gif" width="96" border="0" />
												<br />
												<b>On Failure（失败后）</b>
												<br />(红色箭头)</p>
								</td>
								<td style="BORDER-RIGHT: #cccccc 1px solid">
										<p class="lastInCell">如果您希望任务 2 仅在任务 1 无法成功执行时才开始执行，那么就使用 On Failure 优先级限制将任务 1 链接到任务 2。</p>
								</td>
						</tr>
				</tbody>
		</table>
		<div class="dataTableBottomMargin">
		</div>
		<p>下图给出了具有 On Completion 优先级限制的 ActiveX Script 任务和 Send Mail 任务。当 ActiveX Script 任务完成后（不论成功还是失败），Send Mail 任务都开始运行。</p>
		<div style="WIDTH: 284px">
				<img height="55" alt="图3：具有On Completion优先级限制的ActiveX脚本任务和发送邮件任务" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql25.gif" width="284" border="0" />
				<br />
				<p class="figureCaption">
						<b>图3：具有 On Completion 优先级限制的 ActiveX Script 任务和 Send Mail 任务</b>
				</p>
				<div class="figureRule">
				</div>
		</div>
		<p>您可以配置不同的 Send Mail 任务，一个用于 On Success 限制，另一个用于 On Failure 限制。这两个 Send Mail 任务可以根据 ActiveX Script 的成功或失败来发送不同的邮件。</p>
		<div style="WIDTH: 303px">
				<img height="155" alt="图4：邮件任务" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql26.gif" width="303" border="0" />
				<br />
				<p class="figureCaption">
						<b>图4：邮件任务</b>
				</p>
				<div class="figureRule">
				</div>
		</div>
		<p>您也可以在一个任务上应用多个优先级限制。例如， Send Mail 任务"Admin Notification"可以具有来自脚本#1的 On Success 限制和来自脚本#2 的 On Failure 限制。在这种情况下，DTS 认为其使用逻辑"AND"关系。因此为了发送 Admin Notification 邮件，脚本#1必须成功执行，而脚本#2 必须失败。</p>
		<div style="WIDTH: 306px">
				<img height="155" alt="图5：同一任务多个优先级限制的示例" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql27.gif" width="306" border="0" />
				<br />
				<p class="figureCaption">
						<b>图5：同一任务多个优先级限制的示例</b>
				</p>
				<div class="figureRule">
				</div>
		</div>
		<p>
				<b>连接：访问和移动数据</b>
		</p>
		<p>为了成功地执行复制和转换数据的 DTS 任务，DTS 数据包必须与其来源和目标之间建立有效的连接，同样需要连接到其他数据源（例如查询表）</p>
		<p>在创建数据包时，您可以从有效 OLE DB 提供商和 ODBC 驱动程序列表中选择连接类型，对连接进行配置。可用的连接类型包括：</p>
		<table cellspacing="0" cellpadding="0" border="0">
				<tbody>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>Microsoft 数据访问组件(MDAC)驱动程序</p>
										<table class="dataTable" id="EVHAC" cellspacing="0" cellpadding="0" width="90%">
												<thead>
												</thead>
												<tbody>
														<tr class="record" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="18" alt="dtssql28" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql28.gif" width="14" border="0" />
																		</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">Microsoft OLE DB Provider for SQL Server</p>
																</td>
														</tr>
														<tr class="evenRecord" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="19" alt="dtssql29" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql29.gif" width="19" border="0" />
																		</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">Microsoft 数据链接</p>
																</td>
														</tr>
														<tr class="record" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="19" alt="dtssql30" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql30.gif" width="19" border="0" />
																		</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">Microsoft ODBC Driver for Oracle</p>
																</td>
														</tr>
												</tbody>
										</table>
										<div class="dataTableBottomMargin">
										</div>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>Microsoft Jet 驱动程序</p>
										<table class="dataTable" id="EZIAC" cellspacing="0" cellpadding="0" width="90%">
												<thead>
												</thead>
												<tbody>
														<tr class="record" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="17" alt="dtssql31" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql31.gif" width="20" border="0" />
																		</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">dBase 5</p>
																</td>
														</tr>
														<tr class="evenRecord" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="19" alt="dtssql32" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql32.gif" width="19" border="0" />
																		</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">Microsoft Access</p>
																</td>
														</tr>
														<tr class="record" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="19" alt="dtssql33" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql33.gif" width="20" border="0" />
																		</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">HTML 文件（来源）</p>
																</td>
														</tr>
														<tr class="evenRecord" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="18" alt="dtssql34" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql34.gif" width="21" border="0" />
																		</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">Microsoft Excel 97-2000</p>
																</td>
														</tr>
														<tr class="record" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="18" alt="dtssql35" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql35.gif" width="13" border="0" />
																		</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">Paradox 5.X</p>
																</td>
														</tr>
												</tbody>
										</table>
										<div class="dataTableBottomMargin">
										</div>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>其他驱动程序</p>
										<table class="dataTable" id="ENKAC" cellspacing="0" cellpadding="0" width="90%">
												<thead>
												</thead>
												<tbody>
														<tr class="record" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="19" alt="dtssql36" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql36.gif" width="19" border="0" />
																		</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">文本文件（来源）</p>
																</td>
														</tr>
														<tr class="evenRecord" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="19" alt="dtssql37" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql37.gif" width="19" border="0" />
																		</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">文本文件（目标）</p>
																</td>
														</tr>
														<tr class="record" valign="top">
																<td>
																		<p class="lastInCell">
																				<img height="18" alt="dtssql38" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql38.gif" width="19" border="0" />
																		</p>
																</td>
																<td style="BORDER-RIGHT: #cccccc 1px solid">
																		<p class="lastInCell">其他连接</p>
																</td>
														</tr>
												</tbody>
										</table>
										<div class="dataTableBottomMargin">
										</div>
								</td>
						</tr>
				</tbody>
		</table>
		<p>DTS 允许您使用任何 OLE DB 连接。连接工具栏中的图标为常用连接提供了方便的访问方式。</p>
		<p>下图介绍了一个具有两个连接的数据包。数据被从一个 Access 数据库（来源连接）复制到 SQL Server 生产数据库（目标连接）。</p>
		<div style="WIDTH: 335px">
				<img height="72" alt="图6：具有两个连接的数据包示例" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql39.gif" width="335" border="0" />
				<br />
				<p class="figureCaption">
						<b>图6：具有两个连接的数据包示例</b>
						<br />
						<a href="http://www.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql39_BIG.gif" target="_blank">查看大图。</a>
				</p>
				<div class="figureRule">
				</div>
		</div>
		<p>这个数据包的第一步是一个执行 SQL 任务，该任务检查是否已经存在目标表。如果已经存在，这个表将被删除并重新创建。在成功的完成了执行 SQL 任务后，数据在第二步中被复制到 SQL Server 数据库。如果复制操作失败，则在第三步中发送一封电子邮件。</p>
		<p>
				<b>数据泵：转换数据</b>
		</p>
		<p>DTS 数据泵是一个 DTS 对象，用来驱动数据的导入、导出和转换。在转换数据、数据驱动的查询以及平行数据泵任务中将使用这个数据泵。这些任务将在来源和目标连接中创建数据行组，然后创建数据泵实例，将数据行在来源和目标之间移动。在数据行被复制时，对每一行进行数据转换。</p>
		<p>下图的步骤 2 中，在 Access DB 任务和 SQL Production DB 任务之间使用了一个转换数据任务。转换数据任务是两个连接之间的灰色箭头。</p>
		<div style="WIDTH: 335px">
				<img height="72" alt="图7：转换数据任务的示例" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql40.gif" width="335" border="0" />
				<br />
				<p class="figureCaption">
						<b>图7：转换数据任务的示例</b>
						<br />
						<a href="http://www.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql40_BIG.gif" target="_blank">查看大图。</a>
				</p>
				<div class="figureRule">
				</div>
		</div>
		<p>为了定义从来源连接收集到的数据，您可以为这个转换任务创建一个查询。DTS 支持参数化的查询，允许您在查询执行时定义查询值。</p>
		<p>您可以在该任务的<b>属性</b>对话框中键入这个查询。或者使用数据转换服务查询设计器（Data Transformation Services Query Designer），该工具可以用来为 DTS 任务图形化地创建查询。下图中，使用查询设计器构建了一个将三个表加入到<b>pubs</b>数据库中的查询。</p>
		<div style="WIDTH: 335px">
				<img height="240" alt="图8：数据转换服务查询设计器界面" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql41.gif" width="335" border="0" />
				<br />
				<p class="figureCaption">
						<b>图8：数据转换服务查询设计器界面</b>
						<br />
						<a href="http://www.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql41_BIG.gif" target="_blank">查看大图。</a>
				</p>
				<div class="figureRule">
				</div>
		</div>
		<p>在转换任务中，您也可以定义对数据做出的更改。下表解释了 DTS 提供的内置转换功能。</p>
		<table class="dataTable" id="ECNAC" cellspacing="0" cellpadding="0" width="90%">
				<thead>
						<tr class="stdHeader" valign="top">
								<td id="colEFNAC" width="27%">转换</td>
								<td id="colEJNAC" style="BORDER-RIGHT: #cccccc 1px solid" width="73%">说明</td>
						</tr>
				</thead>
				<tbody>
						<tr class="record" valign="top">
								<td>
										<p class="lastInCell">复制数据栏</p>
								</td>
								<td style="BORDER-RIGHT: #cccccc 1px solid">
										<p class="lastInCell">用来直接将数据从来源复制到目标数据栏中，对数据不进行任何转换。</p>
								</td>
						</tr>
						<tr class="evenRecord" valign="top">
								<td>
										<p class="lastInCell">ActiveX 脚本</p>
								</td>
								<td style="BORDER-RIGHT: #cccccc 1px solid">
										<p class="lastInCell">用来构建定制的转换。请注意，由于转换是逐行进行的，因此ActiveX 脚本可能会影响 DTS 数据包的执行速度。</p>
								</td>
						</tr>
						<tr class="record" valign="top">
								<td>
										<p class="lastInCell">日期事件字符串</p>
								</td>
								<td style="BORDER-RIGHT: #cccccc 1px solid">
										<p class="lastInCell">用来将来源数据栏中的日期或事件转换为目标数据栏中不同的格式。</p>
								</td>
						</tr>
						<tr class="evenRecord" valign="top">
								<td>
										<p class="lastInCell">小写字母字符串</p>
								</td>
								<td style="BORDER-RIGHT: #cccccc 1px solid">
										<p class="lastInCell">用来将来源数据栏中的小写字母转换（如果需要）为目标数据栏的数据类型。</p>
								</td>
						</tr>
						<tr class="record" valign="top">
								<td>
										<p class="lastInCell">大写字母字符串</p>
								</td>
								<td style="BORDER-RIGHT: #cccccc 1px solid">
										<p class="lastInCell">用来将来源数据栏中的所有大写字母转换（如果需要）为目标数据栏的数据类型。</p>
								</td>
						</tr>
						<tr class="evenRecord" valign="top">
								<td>
										<p class="lastInCell">字符串中段</p>
								</td>
								<td style="BORDER-RIGHT: #cccccc 1px solid">
										<p class="lastInCell">用来从来源数据栏中提取子字符串，将其转换，然后将结果复制到目标数据栏中。</p>
								</td>
						</tr>
						<tr class="record" valign="top">
								<td>
										<p class="lastInCell">修剪字符串</p>
								</td>
								<td style="BORDER-RIGHT: #cccccc 1px solid">
										<p class="lastInCell">用于删除来源数据栏中字符串前、后和中间的空白，并将结果复制到目标数据栏中。</p>
								</td>
						</tr>
						<tr class="evenRecord" valign="top">
								<td>
										<p class="lastInCell">读取文件</p>
								</td>
								<td style="BORDER-RIGHT: #cccccc 1px solid">
										<p class="lastInCell">用来打开来源数据栏中所指定的文件的内容，并将其内容复制到目标数据栏中。</p>
								</td>
						</tr>
						<tr class="record" valign="top">
								<td>
										<p class="lastInCell">写入文件</p>
								</td>
								<td style="BORDER-RIGHT: #cccccc 1px solid">
										<p class="lastInCell">用来将来源数据栏（数据）的内容复制到文件中，该文件的路径由第二个来源数据栏（文件名）指定。</p>
								</td>
						</tr>
				</tbody>
		</table>
		<div class="dataTableBottomMargin">
		</div>
		<p>您也可以通过编程创建自己的定制转换。创建定制转换的最快方法是使用活动模板库（Active Template Library，ATL）定制转换模板，该模板包含在 SQL Server 2000 DTS 示例程序中。</p>
		<h3>数据泵错误日志</h3>
		<p>SQL Server 2000中 拥有一种记录转换错误的新方法。您可以定义三种异常日志文件，用于数据包执行过程：错误文本文件、来源错误数据行文件以及目标错误数据行文件。</p>
		<table cellspacing="0" cellpadding="0" border="0">
				<tbody>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>常规错误信息被写入到错误文本文件中。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>如果转换过程失败，那么来源数据行将出现错误，并将该行写入到来源错误数据行文件中。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>如果插入过程失败，那么目标数据行将出现错误，并将该行写入到目标错误数据行文件中。</p>
								</td>
						</tr>
				</tbody>
		</table>
		<p>异常日志文件被定义在转换数据的任务中。每个转换任务可以拥有它自己的日志文件。</p>
		<p>
				<b>数据泵阶段</b>
		</p>
		<p>在默认情况下，数据泵只有一个阶段：数据行转换。这个阶段就是您所配置的在转换数据任务、数据驱动的查询任务以及平行数据泵任务中的数据栏转换，而不选择阶段。</p>
		<p>多数据泵阶段功能是 SQL Server 2000 中所新增的。通过在 SQL Server Enterprise Manager 中选中多段数据泵选项，您可以在操作过程中的不同地方访问数据泵，添加功能。</p>
		<p>在将一行数据从来源复制到目标时，数据泵按照下图所示的基本程序进行操作。</p>
		<div style="WIDTH: 335px">
				<img height="237" alt="图9：数据泵过程" src="http://img.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql42.gif" width="335" border="0" />
				<br />
				<p class="figureCaption">
						<b>图9：数据泵过程</b>
						<br />
						<a href="http://www.microsoft.com/china/technet/images/prodtechnol/sql/2000/deploy/images/dtssql42_BIG.gif" target="_blank">查看大图。</a>
				</p>
				<div class="figureRule">
				</div>
		</div>
		<p>在数据泵处理完最后一行数据后，任务完成，数据泵操作结束。</p>
		<p>如果高级用户需要在数据包中添加功能，使其支持任何数据泵阶段，他可以这样做：</p>
		<table cellspacing="0" cellpadding="0" border="0">
				<tbody>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>为每个定制的数据泵阶段编写一个ActiveX脚本阶段。如果您使用ActiveX脚本功能来定制数据泵阶段，不需要任何数据包以外的代码。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>在 Microsoft Visual C++ 中创建 COM 对象，定制所选中的数据泵阶段。您在数据包以外开发这个程序，转换的每个所选中的阶段都将调用这个程序。与访问数据泵阶段的 ActieX 脚本方法不同的是，ActiveX 脚本方法为每个选中的阶段使用不同的功能和入口点，而这种方法提供了单一入口点，由多个数据泵阶段在任务执行过程中调用。</p>
								</td>
						</tr>
				</tbody>
		</table>
		<div style="MARGIN-TOP: 3px; MARGIN-BOTTOM: 10px">
				<a href="http://www.microsoft.com/china/technet/prodtechnol/sql/2000/deploy/dtssql2k.mspx#top">
						<img height="9" alt="返回页首" src="http://www.microsoft.com/library/gallery/templates/MNP2.Common/images/arrow_px_up.gif" width="7" border="0" />
				</a>
				<a class="topOfPage" href="http://www.microsoft.com/china/technet/prodtechnol/sql/2000/deploy/dtssql2k.mspx#top">返回页首</a>
		</div>
		<a name="ECAAE">
		</a>
		<h2>保存 DTS 数据包的选项</h2>
		<p>下列选项可以保存 DTS 数据包：</p>
		<table cellspacing="0" cellpadding="0" border="0">
				<tbody>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>Microsoft SQL Server</p>
										<p>如果您希望在任何网络中的 SQL Server 实例中保存数据包，请将您的 DTS 数据包保存在 Microsoft SQL Server 上，并保留这些数据包的清单，在数据包开发过程中添加和删除数据包版本。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>SQL Server 2000 元数据服务</p>
										<p>如果您计划跟踪数据包版本、元数据和数据血统信息，请将 DTS 数据包保存在元数据服务上。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>结构化的存储文件</p>
										<p>如果您需要在网络中复制、移动和发送数据包，而不想把数据包存储到 Microsoft SQL Server 数据库中，请将 DTS 数据包保存为结构化的存储文件。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>Microsoft Visual Basic</p>
										<p>如果您希望将其集成到 Visual Basic 程序中，或作为 DTS 应用程序开发的原型，请将由 DTS Designer 和 DTS 导入/导出向导创建的 DTS 数据包保存为 Microsoft Visual Basic 文件。</p>
								</td>
						</tr>
				</tbody>
		</table>
		<div style="MARGIN-TOP: 3px; MARGIN-BOTTOM: 10px">
				<a href="http://www.microsoft.com/china/technet/prodtechnol/sql/2000/deploy/dtssql2k.mspx#top">
						<img height="9" alt="返回页首" src="http://www.microsoft.com/library/gallery/templates/MNP2.Common/images/arrow_px_up.gif" width="7" border="0" />
				</a>
				<a class="topOfPage" href="http://www.microsoft.com/china/technet/prodtechnol/sql/2000/deploy/dtssql2k.mspx#top">返回页首</a>
		</div>
		<a name="ETAAE">
		</a>
		<h2>将 DTS 作为应用程序开发平台</h2>
		<p>DTS Designer 提供了多种数据移动任务的解决方案。DTS 通过提供对 DTS 对象模型的程序化访问，扩展了许多可用的解决方案。使用Microsoft Visual Basic、Microsoft Visual C++ 或其他支持 COM 的应用程序开发系统 ，您可以为您的环境开发一个定制的 DTS 解决方案，使用图形工具中所不支持的功能。</p>
		<p>DTS 以多种不同的方式为开发人员提供支持：</p>
		<table cellspacing="0" cellpadding="0" border="0">
				<tbody>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>构建数据包</p>
										<p>您可以开发极其复杂的数据包，访问对象模型中的所有功能，而不需要使用 DTS Designer 或 DTS 导入/导出向导。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>扩展数据包</p>
										<p>您可以通过定制的任务和转换来增加新的功能，这些任务和转换是专门为您的业务定制的，并且能在DTS中重复使用。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>执行数据包</p>
										<p>DTS 数据包的执行不需要基于任何所提供的工具，可以通过 COM 事件通过编程执行 DTS 数据包和显示过程，允许构建嵌入式或定制的 DTS 执行环境。</p>
								</td>
						</tr>
				</tbody>
		</table>
		<p>所提供的 DTS 程序示例能够帮助您了解 DTS 编程。这些示例与 SQL Server 2000 一同安装。</p>
		<p>如果您要开发 DTS 应用程序，那么您可以重新分配 DTS 文件。更多信息，请参考 SQL Server 2000 光盘的 Redist.txt 文件。</p>
		<h3>更多信息</h3>
		<p>Microsoft SQL Server 2000 Books Online中拥有许多有关 DTS、使用DTS应用程序以及构建定制解决方案的信息。其他信息，请参考下列资源：</p>
		<table cellspacing="0" cellpadding="0" border="0">
				<tbody>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>Microsoft SQL Server Web站点，地址为<a href="http://www.microsoft.com/china/sql/">http://www.microsoft.com/china/sql/</a>。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>Microsoft SQL Server Developer Center，地址为http://msdn.microsoft.com/library/default.asp?URL=/sqlserver/。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>SQL Server Magazine，地址为<a href="http://www.sqlmag.com/">http://www.sqlmag.com/ [英文]</a>。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>Microsoft.public.sqlserver.server和 microsoft.public.sqlserver.datawarehouse新闻组，地址为 news://news.microsoft.com。</p>
								</td>
						</tr>
						<tr>
								<td class="listBullet" valign="top">•</td>
								<td class="listItem">
										<p>关于SQL Server的微软官方课程（Microsoft Official Curriculum）。如需了解最新的课程信息，请访问Microsoft Training and Services Web站点，地址为<a href="http://www.microsoft.com/traincert/default.asp">http://www.microsoft.com/traincert/default.asp [英文]</a></p>
								</td>
						</tr>
				</tbody>
		</table>
		<p>本文档所提供的信息资料仅代表Microsoft公司在信息发布当日就研讨活动所围绕的问题持有的临时观点。鉴于Microsoft公司必须针对瞬息万变的市场状况不断做出相应调整，故而，本文档内容不应被解释为Microsoft方面所做出的任何承诺，与此同时，Microsoft也无法在发布之日后继续保证文件所含信息的准确性。</p>
		<p>本白皮书仅供用于信息参考目的。Microsoft并未在本文档中提供任何形式的保证、明示或暗示。</p>
		<p>遵守所有适用版权法律是文档使用者所应承担的义务。Microsoft公司虽未在版权保护下就与本文档相关的权利做出任何限定，但是，任何人未经Microsoft公司书面授权许可，均不得出于任何目的、以任何形式、利用任何手段（电子、机械、影印、录音等）将本文档的任何组成部分制作成拷贝、存储或引入检索系统、亦或向任何对象进行传送。 </p>
		<p>Microsoft公司可能就本文档所涉及的主题拥有专利、专利申请、商标、版权或其它形式的知识产权。除非已同Microsoft公司签订书面许可协议，并根据协议条款获得明确授权，任何出示本文档的行为均无法使您具备针对上述专利、商标、版权或其它知识产权加以利用的许可权限。</p>
		<p>?2000 Microsoft Corporation. 保留所有权利.</p>
		<p>Microsoft、ActiveX、JScript、Visual Basic和Visual C++ 均系Microsoft公司在美国和/或其它国家所拥有的注册商标或商标。</p>
		<p>本文档所涉及的其它公司和产品的真实名称均为其各自所有者持有的商标。</p>
<img src ="http://www.blogjava.net/Daniel2005/aggbug/83264.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Daniel2005/" target="_blank">泌鲁沙夫</a> 2006-11-24 15:07 <a href="http://www.blogjava.net/Daniel2005/articles/83264.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VB+ADODB</title><link>http://www.blogjava.net/Daniel2005/articles/59333.html</link><dc:creator>泌鲁沙夫</dc:creator><author>泌鲁沙夫</author><pubDate>Fri, 21 Jul 2006 00:42:00 GMT</pubDate><guid>http://www.blogjava.net/Daniel2005/articles/59333.html</guid><wfw:comment>http://www.blogjava.net/Daniel2005/comments/59333.html</wfw:comment><comments>http://www.blogjava.net/Daniel2005/articles/59333.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Daniel2005/comments/commentRss/59333.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Daniel2005/services/trackbacks/59333.html</trackback:ping><description><![CDATA[rs.Open StrSql, Conn, adOpenDynamic, adLockOptimistic<br />最好是使用这个，如果使用adOpenForword之类的，可能会出现错误！！！<br /><img src ="http://www.blogjava.net/Daniel2005/aggbug/59333.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Daniel2005/" target="_blank">泌鲁沙夫</a> 2006-07-21 08:42 <a href="http://www.blogjava.net/Daniel2005/articles/59333.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VB中如何使用存储过程返回值</title><link>http://www.blogjava.net/Daniel2005/articles/27352.html</link><dc:creator>泌鲁沙夫</dc:creator><author>泌鲁沙夫</author><pubDate>Tue, 10 Jan 2006 03:41:00 GMT</pubDate><guid>http://www.blogjava.net/Daniel2005/articles/27352.html</guid><wfw:comment>http://www.blogjava.net/Daniel2005/comments/27352.html</wfw:comment><comments>http://www.blogjava.net/Daniel2005/articles/27352.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Daniel2005/comments/commentRss/27352.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Daniel2005/services/trackbacks/27352.html</trackback:ping><description><![CDATA[<P><FONT color=#0000ff>Public Function GetCouponCode() As Long<BR>&nbsp;&nbsp;&nbsp; Dim cmdGetCouponNo As New ADODB.Command<BR>&nbsp;&nbsp;&nbsp; Dim param As ADODB.Parameter<BR>&nbsp;&nbsp;&nbsp; On Error GoTo ErrHandle1<BR>&nbsp;&nbsp;&nbsp; </FONT></P>
<P><FONT color=#0000ff>&nbsp;&nbsp;&nbsp; cmdGetCouponNo.ActiveConnection = cnn<BR>&nbsp;&nbsp;&nbsp; cmdGetCouponNo.CommandText = "GET_COUPON_NO"<BR>&nbsp;&nbsp;&nbsp; cmdGetCouponNo.CommandType = adCmdStoredProc<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Set param = cmdGetCouponNo.CreateParameter("Output", adInteger, adParamOutput)<BR>&nbsp;&nbsp;&nbsp; cmdGetCouponNo.Parameters.Append param<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; cmdGetCouponNo.Execute<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; GetCouponCode = cmdGetCouponNo.Parameters("Output").Value<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; If GetCouponCode &gt; 999999 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GetCouponCode = 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MsgBox "此数字已超出999999" &amp; vbCrLf &amp; "消除OPERATOR_COUPON表中信息！", vbInformation, "Warning"<BR>&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Set cmdGetCouponNo = Nothing<BR>Exit Function<BR>ErrHandle1:<BR>&nbsp;&nbsp;&nbsp; GetCouponCode = 0<BR>End Function</FONT></P><img src ="http://www.blogjava.net/Daniel2005/aggbug/27352.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Daniel2005/" target="_blank">泌鲁沙夫</a> 2006-01-10 11:41 <a href="http://www.blogjava.net/Daniel2005/articles/27352.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VB.NET中的多窗体编程：升级到 .NET</title><link>http://www.blogjava.net/Daniel2005/articles/22252.html</link><dc:creator>泌鲁沙夫</dc:creator><author>泌鲁沙夫</author><pubDate>Fri, 02 Dec 2005 07:49:00 GMT</pubDate><guid>http://www.blogjava.net/Daniel2005/articles/22252.html</guid><wfw:comment>http://www.blogjava.net/Daniel2005/comments/22252.html</wfw:comment><comments>http://www.blogjava.net/Daniel2005/articles/22252.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Daniel2005/comments/commentRss/22252.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Daniel2005/services/trackbacks/22252.html</trackback:ping><description><![CDATA[<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14><B>前言</B></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>在微软 Visual Basic 6.0 中，一条简单的 “Form2.Show” 语句就能显示项目中的第二窗体 (Form2)。然而，它在 Visaul Basic .NET 中却行不通了，因为 .NET 版在窗体处理机制上有了很大的变化。刚刚转向 .NET 版的 Visaul Basic 程序员实在难以接受这么大的变化，因为现在连“显示第二窗体”这么简单的任务都无从下手。我希望能够通过本文向大家介绍 Visaul Basic .NET 与早期的 Visual Basic 在窗体处理机制上有哪些不同之处，以及如何按照 .NET 的模式进行多窗体编程。</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14><B>Visual Basic 6.0 对 Visual Basic .NET</B></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>窗体(窗体类)正如其它类一样，无论在哪个版本的 Visual Basic 中都是必不可少的。窗体也有属性、方法和事件，且在同一个项目中也允许创建多个窗体实例 (参见 http://msdn.microsoft.com/library/en-us/off2000/html/defInstance.asp)。例如：假设你在 Visual Basic 6.0 项目中定义了一个窗体 Form2 ，则你可以创建它的 3 个实例并同时显示出来。代码如下：</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Dim myFirstForm As Form2</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Dim mySecondForm As Form2</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Dim myThirdForm As Form2</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Set myFirstForm = New Form2</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Set mySecondForm = New Form2</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Set myThirdForm = New Form2</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>myFirstForm.Show</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>mySecondForm.Show</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>myThirdForm.Show</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>以上代码用 3 条 Set 语句生成了 3 个 Form2 实例。你可以把它原封不动地搬到 Visual Basic .NET 中运行，它照样能够正确显示 3 个 Form2 窗体。在这里，“Form2” 其实相当于一个普通的类。Visual Basic 6.0 允许代码直接访问尚未实例化的窗体类；然而Visual Basic .NET 却规定在访问任何类之前都要进行实例化，而且必须借助实例来访问类。这种变化当然有可能造成许多疑惑。Visual Basic 6.0 等早期版本能自动生成每个窗体的默认实例，从而允许直接通过窗体名称来访问窗体。例如：在 Visual Basic 6.0 项目中，可以直接用代码 “Form2.Show” 显示 Form2 的默认实例；然而在 Visual Basic .NET 中，这么做只会引发错误，因为 Visual Basic .NET 既不会创建默认的窗体实例，也不允许直接访问尚未实例化的窗体类。</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>这就是 Visual Basic .NET 与早期 Visual Basic 在窗体处理机制上的关键区别——你只有先创建窗体实例，然后才可以显示窗体外观、访问窗体属性及其控件。它们还有另一个区别：Visual Basic 6.0 项目自动创建的默认窗体实例都能被当成全局变量使用，也就是说，项目中的任何代码都能直接引用窗体，并且每次被引用的都是该窗体的同一个实例。例如：你可以在窗体中 button 控件的 Click 事件处理程序里用代码 “Form2.Show” 显示 Form2 窗体，然后用下列代码改变 Form2 中某个 textbox 控件 (TextBox1)的内容：</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Form2.TextBox1.Text = "Fred"</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>可是，你在 Visual Basic .NET 中运行它却会得到一条错误消息：“Reference to a Non-Shared Member Requires an Object Reference”(引用非共享类成员必须使用对象指针)。这是在提醒你：你正在访问的类尚未进行实例化。有一个简便的解决方案：当你在调试过程中得到上述错误消息时，就把相应的语句：</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Form2.Show()</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>改成：</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Dim myForm2 As New Form2()</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>myForm2.Show()</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>此方案适用于大多数场合。然而，当项目中还有其它代码访问同一个 Form2 实例 (比如改变其中 TextBox1 的文本) 时，你可能会考虑把下列语句：</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Form2.TextBox1.Text = "Fred"</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>改成：</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Dim myForm2 As New Form2()</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>myForm2.TextBox1.Text = "Fred"</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>不幸的是，这段代码创建了一个新的 Form2 实例，结果你所访问的窗体不再是原先的 Form2 ，这岂不麻烦了！更坏的是，你不会因此而得到任何错误消息提示，同时你先前调用 Show() 显示的 Form2 窗体也不会发生任何变化。</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14><B>升级向导如何解决它</B></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>如果你用升级向导 (Upgrade Wizard) 把 Visual Basic 6.0 项目升级为 Visual Basic .NET 版，则它会在每个窗体中自动添加一段特殊代码，通过显式创建窗体实例来模拟早期 Visual Basic 版本中的默认实例化机制。此段代码被包裹于标号为 “Upgrade Support”的代码区块内，借助一个新增的 Shared 属性来生成当前窗体的实例：</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Private Shared m_vb6FormDefInstance As Form1</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Private Shared m_InitializingDefInstance As Boolean</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Public Shared Property DefInstance() As Form1</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Get</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>If m_vb6FormDefInstance Is Nothing _</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>OrElse m_vb6FormDefInstance.IsDisposed Then</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>m_InitializingDefInstance = True</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>m_vb6FormDefInstance = New Form1()</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>m_InitializingDefInstance = False</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>End If</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>DefInstance = m_vb6FormDefInstance</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>End Get</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Set(ByVal Value As Form1)</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>m_vb6FormDefInstance = Value</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>End Set</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>End Property</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>代码中的 DefInstance 是一个 Shared 属性，它能以 “窗体名.DefInstance” 的形式直接访问。它所在项目中的任何代码访问它都将得到同一个窗体实例。这样，你就能模拟 Visual Basic 6.0 项目对窗体的直接引用了，只不过在代码中以 “Form2.DefInstance” 代替 “Form2” 而已。</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>这时，你只需用 Form2.DefInstance.Show() 和Form2.DefInstance.TextBox1.Text = "Fred" 分别替换原先对 Form2 相应的直接引用就大功告成了。假如你不用升级向导，而是在 Visual Basic .NET 窗体中手工插入上述代码 (以及升级向导在窗体的 New过程中自动添加的代码)，也行。当然了，你并不一定非要修改窗体代码，因为有一种编程模式可以在 .NET 项目中模拟默认窗体实例的创建。本文将用余下的篇幅来介绍这种编程模式。</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14><B>.NET 窗体之间的交互</B></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>在 Visual Basic 6.0 等早期版本中，多个窗体之间的交互通常需要借助默认窗体实例来完成。下面我将结合某些具体的编程任务来讲解如何在 .NET 下实现多窗体交互，希望它能对你的开发任务有所帮助。</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14><B>保持窗体引用的全局性</B></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>前面提到，进行 .NET 窗体编程时应该牢牢把握下列原则：在访问窗体之前，你必须进行窗体实例化；如果在项目中有多处代码访问同一窗体，则你必须把它的同一实例指针传递给这些代码。对于早已习惯了直接把默认窗体实例当成全局变量来使用的 Visual Basic 6.0 程序员来说，这可是个严重的挑战。好在 .NET 为你提供了两条出路：其一，把窗体实例指针保存在全局变量中；其二，把窗体实例指针传递给任何需要访问它的窗体、类、模块或者过程。</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14><B>.NET 中的数值全局化</B></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>我以前曾经指出，Visual Basic .NET 不支持全局变量，现在我又要说，在 .NET 中可以在某种程度上实现数值全局化。这算不算此一时，彼一时？不，我不是那种人。Visual Basic .NET 确实不支持全局变量，然而它借助 Shared (相当于 C# 中的 static) 变量却能模拟全局变量。事实上，前面介绍的 Visual Basic 升级向导自动添加到窗体代码中的 DefInstance 属性就是 Shared 类成员。无论容纳 DefInstance 属性的窗体类是否已经实例化，它都能被项目中的任何代码所引用。象这样的 Shared 属性不就相当于全局变量吗？因此，你可以创建这样的类：</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Public Class myForms</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Private Shared m_CustomerForm As CustomerForm</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Public Shared Property CustomerForm() As CustomerForm</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Get</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Return m_CustomerForm</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>End Get</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Set(ByVal Value As CustomerForm)</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>m_CustomerForm = Value</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>End Set</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>End Property</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>End Class</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>你需要在首次实例化一个窗体时，把该窗体的实例保存到一个类中：</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Dim myNewCust As New CustomerForm()</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>myNewCust.Show()</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>myForms.CustomerForm = myNewCust</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>这里的 CustomerForm 属性值就是你的窗体实例。于是，其它代码就能从项目的任何地方通过它来间接访问你的窗体了：</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Module DoingStuffWithForms</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Sub DoExcitingThings()</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>myForms.CustomerForm.Text = _</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>DateTime.Now().ToLongTimeString</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>End Sub</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>End Module</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>象这样把窗体实例保存为属性值就能按照你的要求模拟 Visual Basic 6.0 中的全局变量。如此模拟的“全局变量”其作用域比类域 (class scope) 高一个层次。所谓类域，是指变量仅仅在定义它的类(确切地说，应该包括模块、类或窗体)中有效。比类域还低一层次的是过程域 (procedure scope)，即变量仅仅在定义它的例程中有效。 </TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14><B>窗体指针在项目中的传递</B></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>除了把窗体实例全局化以外，你还可以把窗体类指针保存在变量中传递给需要访问该窗体的例程。假设你有一个窗体 Form1，并希望在点击 Form1 中某个按钮 (Button1) 时打开另第二窗体 Form2 ，然后在点击第二窗体 Form2 中的另一个按钮 (Button2) 时进行某项计算。你可以把整个代码都写在 Form1 中，即：</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Public Class Form1</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Inherits System.Windows.Forms.Form</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Dim myForm2 As Form2</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Private Sub Button1_Click(ByVal sender As System.Object, _</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>ByVal e As System.EventArgs) Handles Button1.Click</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>myForm2 = New Form2()</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>myForm2.Show()</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>End Sub</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Private Sub Button2_Click(ByVal sender As System.Object, _</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>ByVal e As System.EventArgs) Handles Button2.Click</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Calculations.CompoundInterestCalc(myForm2)</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>End Sub</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>End Class</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>无论是把窗体指针全局化，还是把它以参数的形式传递，都是可行的。然而，你必须根据项目的需要选择最佳方案。当 .NET 项目中只有少数几个过程需要访问特定窗体时，我建议你给这些过程增加一个参数，以在必要时接受窗体指针。当你的项目有太多过程需要访问该窗体时，你就应该考虑设置一个全局窗体指针变量。当然了，你最好还是考虑调整项目代码结构，使得真正访问该窗体的类或者过程只有一个。如果你希望用窗体来显示登录信息，则你可以先创建一个类，把窗体实例保存为它的 Shared 类成员，然后添加一个 Shared 方法 WriteToLogWindow 来完成实际的窗体访问。于是，项目中的任何代码只需调用此 WriteToLogWindow 方法就能间接访问显示登录信息的窗体了：</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Public Class Log</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Private Shared m_LogForm As Form2</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Public Shared Property LogForm() As Form2</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Get</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Return m_LogForm</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>End Get</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Set(ByVal Value As Form2)</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>m_LogForm = Value</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>End Set</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>End Property</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Public Shared Sub WriteToLogWindow(ByVal Message As String)</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Dim sb As New _</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>StringBuilder(m_LogForm.txtLogInfo.Text)</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>sb.Append(Environment.NewLine)</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>sb.Append(Message)</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>m_LogForm.txtLogInfo.Text = sb.ToString()</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>End Sub</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>End Class</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14><B>读取和改变窗体内的信息</B></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>到现在为止，我们讨论的只是如何创建和访问窗体实例，而没有涉及如何读取或改变窗体内的信息。如果你的窗体已经按照前述方法实例化，并且访问窗体的代码都位于窗体所在的项目中，则你可以直接操作窗体中的任何控件来读取和改变窗体内的信息。但我觉得这样并不理想。与其直接访问窗体中的文本框、按钮等控件，还不如增加一个 Public 属性，通过它来控制窗体中的控件。如果你有意尝试这种特殊的窗体访问方式，请跟我来： </TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>在 Visual Basic .NET 中新建一个 Windows 应用程序项目。</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>此时项目中已经自动生成了一个窗体 Form1 。现在添加另一个窗体 Form2 ：在“解决方案资源管理器”中按右键单击项目名称 -&gt; “添加” -&gt; “添加 Windows 窗体” -&gt; 点击“打开”以接受默认名称 Form2.vb 。</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>在 Form1 中添加两个按钮，分别按照默认值命名为 Button1 和 Button2 ，并且调整它们在窗体中的位置以免重叠。</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>在 Form2 中添加一个简单文本框，按照默认值命名为 TextBox1 </TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>把下列代码添加到 Form2 的“End Class”前面 (在“解决方案资源管理器”中按右键单击 “Form2”-&gt; “查看代码”，再粘贴下列代码)：</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Public Property CustomerName() As String</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Get</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Return TextBox1.Text</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>End Get</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Set(ByVal Value As String)</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>TextBox1.Text = Value</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>End Set</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>End Property</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>接下来要做的是：</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>a. 切换到 Form1 的代码，在 “Inherits System.Windows.Forms.Form” 后面增加一行：</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Dim myForm2 As New Form2()</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>b. 在 Form1 中双击Button1 按钮，在它的 Click 事件处理程序代码中输入下列代码： </TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>myForm2.CustomerName = "Fred"</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>myForm2.Show()</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>c. 在 Form1 中双击Button2 按钮，在它的 Click 事件处理程序代码中输入下列代码： </TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>MessageBox.Show(myForm2.CustomerName)</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>myForm2.CustomerName = "Joe"</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>d. 按 F5 运行项目，并点击窗体中的 Button1 和 Button2 按钮，以观察代码运行情况。 </TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>表面看来，通过 CustomerName 属性来访问 Form2 与直接访问 Form2 非常相似。然而，这种间接的窗体访问方式能够带来很多好处，其中最重要的一点就在于它实现了更高的抽象性。换言之，哪怕你不知道 Form2 中控件的任何细节 (比如：窗体中是否包含 textbox 控件) ，也能与 Form2 交换数据；你所要做的只是读取或设置 CustomerName 属性值而已。有了这种抽象，你就能在修改 Form2 的实现时不影响项目中的其它代码，因而大大简化了整个项目代码的维护。单从本文的例子来看，这种基于属性的窗体编程模式似乎并不比常规方式简单。然而，它以属性的形式隐藏了窗体的全部细节，故能用简洁、一致的代码来访问窗体。所以，它在一些相当复杂的用户界面编程中能够大显身手。总而言之，通过属性值来访问窗体及其控件的编程模式虽然不太直观，却对程序员很有价值：它不但比直接访问窗体的编程模式来得更专业，而且让整个项目的代码清晰易读。</TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14><B>结论</B></TD></TR></TBODY></TABLE>
<TABLE width="100%">
<TBODY>
<TR>
<TD class=a14>Visual Basic .NET 取消了早期版本中的“默认窗体实例”，却引起了不少 .NET 编程新手的困惑。Visual Basic .NET 规定，只有通过引用窗体实例，才能访问窗体的属性、方法及其控件。你所保存的窗体实例指针应该尽量让整个项目都能直接访问到它。Visual Basic .NET 的窗体处理机制已经变得更合理、更强大，可对于刚接触 .NET 的程序员来说，它的改进偏偏是造成许多困惑的根源。</TD></TR></TBODY></TABLE><img src ="http://www.blogjava.net/Daniel2005/aggbug/22252.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Daniel2005/" target="_blank">泌鲁沙夫</a> 2005-12-02 15:49 <a href="http://www.blogjava.net/Daniel2005/articles/22252.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如何利用VB来开发手机短信程序</title><link>http://www.blogjava.net/Daniel2005/articles/20044.html</link><dc:creator>泌鲁沙夫</dc:creator><author>泌鲁沙夫</author><pubDate>Wed, 16 Nov 2005 04:56:00 GMT</pubDate><guid>http://www.blogjava.net/Daniel2005/articles/20044.html</guid><wfw:comment>http://www.blogjava.net/Daniel2005/comments/20044.html</wfw:comment><comments>http://www.blogjava.net/Daniel2005/articles/20044.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/Daniel2005/comments/commentRss/20044.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/Daniel2005/services/trackbacks/20044.html</trackback:ping><description><![CDATA[<P>'----------------------------------------------------------------<BR>' 系统名:&nbsp; 短信自动转发系统<BR>' 版本号:&nbsp; V1.0<BR>' 模块名:&nbsp; mdlSend<BR>' 功能:&nbsp;&nbsp;&nbsp; 短信接收和转发<BR>' 作成者:&nbsp; 系统名:&nbsp; 短信自动转发系统<BR>' 版本号:&nbsp; V1.0<BR>' 模块名:&nbsp; mdlSend<BR>' 功能:&nbsp;&nbsp;&nbsp; 短信接收和转发<BR>' 作成者:&nbsp; Daniel<BR>' 备注:<BR>'----------------------------------------------------------------<BR>Module mdlSend<BR>&nbsp;&nbsp;&nbsp; Const prex = "0891"<BR>&nbsp;&nbsp;&nbsp; Const midx = "11000D91"<BR>&nbsp;&nbsp;&nbsp; Const sufx = "000800"<BR>&nbsp;&nbsp;&nbsp; '----------------------------------------------------------------<BR>&nbsp;&nbsp;&nbsp; ' 过程名:&nbsp;&nbsp;&nbsp; telc<BR>&nbsp;&nbsp;&nbsp; ' 功能:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 电话号码去反，如果为奇数，最后一位的前面加“F”<BR>&nbsp;&nbsp;&nbsp; '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 如 13014151601变为3110141506F1<BR>&nbsp;&nbsp;&nbsp; ' 输入参数:&nbsp; 电话号码<BR>&nbsp;&nbsp;&nbsp; ' 输出参数:&nbsp; 无<BR>&nbsp;&nbsp;&nbsp; ' 返回值:&nbsp;&nbsp;&nbsp; 经过转换的电话号码<BR>&nbsp;&nbsp;&nbsp; '----------------------------------------------------------------&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Public Function telc(ByVal num As String) As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim tl As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim ltem, rtem, ttem As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim ti As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ttem = ""<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' MessageBox.Show(num)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tl = Len(num)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'If (tl &lt;&gt; 11) And (tl &lt;&gt; 13) Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '&nbsp;&nbsp;&nbsp; MsgBox("错误的号码：" &amp; tl)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '&nbsp;&nbsp;&nbsp; Exit Function<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'If tl = 11 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '&nbsp;&nbsp;&nbsp; tl = tl + 2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '&nbsp;&nbsp;&nbsp; num = "86" &amp; num<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If num.Substring(0, 2) &lt;&gt; "86" Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tl = tl + 2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; num = "86" &amp; num<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For ti = 1 To tl Step 2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ltem = Mid(num, ti, 1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rtem = Mid(num, ti + 1, 1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If ti = tl Then rtem = "F"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ttem = ttem &amp; rtem &amp; ltem<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next ti<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; telc = ttem<BR>&nbsp;&nbsp;&nbsp; End Function<BR>&nbsp;&nbsp;&nbsp; '----------------------------------------------------------------<BR>&nbsp;&nbsp;&nbsp; ' 过程名:&nbsp;&nbsp;&nbsp; telcX<BR>&nbsp;&nbsp;&nbsp; ' 功能:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 同telc函数相反<BR>&nbsp;&nbsp;&nbsp; '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 如 3110141506F1变为13014151601<BR>&nbsp;&nbsp;&nbsp; ' 输入参数:&nbsp; 电话号码<BR>&nbsp;&nbsp;&nbsp; ' 输出参数:&nbsp; 无<BR>&nbsp;&nbsp;&nbsp; ' 返回值:&nbsp;&nbsp;&nbsp; 经过转换的电话号码<BR>&nbsp;&nbsp;&nbsp; '----------------------------------------------------------------&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Public Function telcX(ByVal num As String) As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim tl As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim ltem, rtem, ttem As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim ti As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ttem = ""</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tl = Len(num)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If tl = 14 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tl = tl - 2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; num = num.Substring(2, tl)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For ti = 1 To tl Step 2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ltem = Mid(num, ti, 1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rtem = Mid(num, ti + 1, 1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ttem = ttem &amp; rtem &amp; ltem<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next ti<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If ttem.Substring(ttem.Length - 1, 1) = "F" Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; telcX = ttem.Substring(0, ttem.Length - 1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; telcX = ttem<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp; End Function<BR>&nbsp;&nbsp;&nbsp; '----------------------------------------------------------------<BR>&nbsp;&nbsp;&nbsp; ' 过程名:&nbsp;&nbsp;&nbsp; TimeFormat<BR>&nbsp;&nbsp;&nbsp; ' 功能:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 显示日期<BR>&nbsp;&nbsp;&nbsp; '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 如 402180414174变为2004-12-08 14:14:47<BR>&nbsp;&nbsp;&nbsp; ' 输入参数:&nbsp; 日期<BR>&nbsp;&nbsp;&nbsp; ' 输出参数:&nbsp; 无<BR>&nbsp;&nbsp;&nbsp; ' 返回值:&nbsp;&nbsp;&nbsp; 经过转换的日期<BR>&nbsp;&nbsp;&nbsp; '----------------------------------------------------------------&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Public Function TimeFormat(ByVal num As String) As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim tl As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim ltem, rtem, ttem As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim ti As Integer</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ttem = ""<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tl = Len(num)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If tl = 14 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tl = tl - 2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; num = num.Substring(2, tl)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For ti = 1 To tl Step 2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ltem = Mid(num, ti, 1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rtem = Mid(num, ti + 1, 1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ttem = ttem &amp; rtem &amp; ltem<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next ti<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ttem = "20" &amp; ttem</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TimeFormat = ttem.Substring(0, 4) &amp; "-" &amp; ttem.Substring(4, 2) &amp; "-" &amp; ttem.Substring(6, 2) _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp; " " &amp; ttem.Substring(8, 2) &amp; ":" &amp; ttem.Substring(10, 2) &amp; ":" &amp; ttem.Substring(12, 2)</P>
<P><BR>&nbsp;&nbsp;&nbsp; End Function</P>
<P>&nbsp;&nbsp;&nbsp; '----------------------------------------------------------------<BR>&nbsp;&nbsp;&nbsp; ' 过程名:&nbsp;&nbsp;&nbsp; chg<BR>&nbsp;&nbsp;&nbsp; ' 功能:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Unicode码为中文转换<BR>&nbsp;&nbsp;&nbsp; ' 输入参数:&nbsp; Unicode码<BR>&nbsp;&nbsp;&nbsp; ' 输出参数:&nbsp; 无<BR>&nbsp;&nbsp;&nbsp; ' 返回值:&nbsp;&nbsp;&nbsp; 中文<BR>&nbsp;&nbsp;&nbsp; '----------------------------------------------------------------&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Public Function chg(ByVal rmsg As String, ByVal strGS As String) As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim tep As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim temp As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim i As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim b As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim a As Integer</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tep = rmsg<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = Len(tep)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chg = ""</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If strGS = "08" Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b = i / 4<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For i = 1 To b<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; temp = "&amp;H" &amp; Mid(tep, (i - 1) * 4 + 1, 4)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chg = chg &amp; ChrW(CInt(Val(temp)))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next i<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chg = getChar(rmsg)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If</P>
<P>&nbsp;&nbsp;&nbsp; End Function</P>
<P>&nbsp;&nbsp;&nbsp; '----------------------------------------------------------------<BR>&nbsp;&nbsp;&nbsp; ' 过程名:&nbsp;&nbsp;&nbsp; ascg<BR>&nbsp;&nbsp;&nbsp; ' 功能:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 中文转换为Unicode码，同chg相反<BR>&nbsp;&nbsp;&nbsp; ' 输入参数:&nbsp; 中文<BR>&nbsp;&nbsp;&nbsp; ' 输出参数:&nbsp; 无<BR>&nbsp;&nbsp;&nbsp; ' 返回值:&nbsp;&nbsp;&nbsp; Unicode码<BR>&nbsp;&nbsp;&nbsp; '----------------------------------------------------------------&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Public Function ascg(ByVal smsg As String) As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim si, sb As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim stmp As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim stemp As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim tmp As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sb = Len(smsg)<BR>&nbsp;&nbsp;&nbsp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sp;&nbsp;&nbsp; If ccc &lt;= 255 And ccc &gt;= 0 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bbb = "00" &amp; bbb<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '&nbsp;&nbsp;&nbsp; End If</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; '&nbsp;&nbsp;&nbsp; aaa = aaa &amp; bbb</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'Next i<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 'chg = aaa<BR>&nbsp;&nbsp;&nbsp; End Function<BR>&nbsp;&nbsp;&nbsp; '----------------------------------------------------------------<BR>&nbsp;&nbsp;&nbsp; ' 过程名:&nbsp;&nbsp;&nbsp; Sendsms<BR>&nbsp;&nbsp;&nbsp; ' 功能:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' 输入参数:&nbsp; 短信中心号码，接收短信的手机的号码，短信内容<BR>&nbsp;&nbsp;&nbsp; ' 输出参数:&nbsp; 短信长度，pdu字符串<BR>&nbsp;&nbsp;&nbsp; ' 返回值:&nbsp;&nbsp;&nbsp; 无<BR>&nbsp;&nbsp;&nbsp; '----------------------------------------------------------------&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Public Function Sendsms(ByVal csca As String, ByVal num As String, ByVal msg As String) As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim psmsc As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim pnum As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim pmsg As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim intLength As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim leng As String</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intLength = Trim(Len(msg))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intLength = 2 * intLength<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; leng = Hex(intLength)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If intLength &lt; 16 Then leng = "0" &amp; leng<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; psmsc = Trim(telc(csca))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msg = msg.Replace(Chr(13), "").Replace(Chr(0), "")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msg = msg.Replace(Chr(20), "").Replace(Chr(0), "")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; msg = msg.Replace(Chr(26), "").Replace(Chr(0), "")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pnum = Trim(telc(num))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pmsg = Trim(ascg(msg))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Sendsms = prex &amp; psmsc &amp; midx &amp; pnum &amp; sufx &amp; leng &amp; pmsg<BR>&nbsp;&nbsp;&nbsp; End Function</P>
<P>&nbsp;&nbsp;&nbsp; '----------------------------------------------------------------<BR>&nbsp;&nbsp;&nbsp; ' 过程名:&nbsp;&nbsp;&nbsp; getChar<BR>&nbsp;&nbsp;&nbsp; ' 功能:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' 输入参数:&nbsp; 字符串，7Bit号码<BR>&nbsp;&nbsp;&nbsp; ' 输出参数:&nbsp; 字符串，字母或数字<BR>&nbsp;&nbsp;&nbsp; ' 返回值:&nbsp;&nbsp;&nbsp; 无<BR>&nbsp;&nbsp;&nbsp; '----------------------------------------------------------------&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Private Function getChar(ByVal strIn As String) As String</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim strText As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim strRezult As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim strChar As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim intI As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim intJ As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim blnFalg As Boolean<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim strTmp As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim strTmp1 As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim intlen As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim str8Bit(7) As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim str7Bit(8) As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim strTextTmp As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim intAsc As Integer</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For intI = 1 To strIn.Length<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strChar = strIn.Substring(intI - 1, 1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Select Case strChar ' Evaluate Number.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case "F"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strText = strText + "1111"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case "E"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strText = strText + "1110"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case "D"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strText = strText + "1101"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case "C"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp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p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strText = strText + "0011"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case "2"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strText = strText + "0010"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case "1"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strText = strText + "0001"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case "0"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strText = strText + "0000"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Select<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; blnFalg = True<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Do While blnFalg<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If strText.Length &lt;= 56 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intlen = strText.Length<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; blnFalg = False<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intlen = 56<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strTmp = strText.Substring(0, intlen)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If strText.Length &gt; 56 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strText = strText.Substring(56, strText.Length - 56)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For intI = 0 To intlen / 8 - 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; str8Bit(intI) = strTmp.Substring(intI * 8, 8)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If intI = 0 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; str7Bit(intI) = str8Bit(intI).Substring(intI + 1, 8 - intI - 1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strTextTmp = str7Bit(intI)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intAsc = getCF(strTextTmp)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strRezult = strRezult + Chr(intAsc)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Else<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; str7Bit(intI) = str8Bit(intI).Substring(intI + 1, 8 - intI - 1) + strTmp1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strTextTmp = str7Bit(intI)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intAsc = getCF(strTextTmp)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strRezult = strRezult + Chr(intAsc)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strTmp1 = str8Bit(intI).Substring(0, intI + 1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If strTmp1.Length = 7 Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; str7Bit(intI) = strTmp1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strTextTmp = str7Bit(intI)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intAsc = getCF(strTextTmp)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strRezult = strRezult + Chr(intAsc)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Loop<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getChar = strRezult<BR>&nbsp;&nbsp;&nbsp; End Function</P>
<P>&nbsp;&nbsp;&nbsp; ' 过程名:&nbsp;&nbsp;&nbsp; getCharShi<BR>&nbsp;&nbsp;&nbsp; ' 功能:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16进制转换为10进制<BR>&nbsp;&nbsp;&nbsp; '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 如26转换为38<BR>&nbsp;&nbsp;&nbsp; ' 输入参数:&nbsp; 16进制字符串<BR>&nbsp;&nbsp;&nbsp; ' 输出参数:&nbsp; 无<BR>&nbsp;&nbsp;&nbsp; ' 返回值:&nbsp;&nbsp;&nbsp; 10进制字符串<BR>&nbsp;&nbsp;&nbsp; Public Function getCharShi(ByVal strIn As String) As Integer</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim strText As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim strChar As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim intI As Integer</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For intI = 1 To strIn.Length<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strChar = strIn.Substring(intI - 1, 1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Select Case strChar ' Evaluate Number.<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case "F"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strText = strText + "1111"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case "E"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strText = strText + "1110"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case "D"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strText = strText + "1101"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case "C"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strText = strText + "1100"<BR>&nbsp;&nbsp;&nbsp;&nbs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sp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case "2"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strText = strText + "0010"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case "1"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strText = strText + "0001"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case "0"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strText = strText + "0000"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End Select<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Next</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getCharShi = getCFShi(strText)</P>
<P>&nbsp;&nbsp;&nbsp; End Function<BR>&nbsp;&nbsp;&nbsp; '----------------------------------------------------------------<BR>&nbsp;&nbsp;&nbsp; ' 过程名:&nbsp;&nbsp;&nbsp; getCFShi<BR>&nbsp;&nbsp;&nbsp; ' 功能:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 七位的二进制转换程十进制<BR>&nbsp;&nbsp;&nbsp; ' 输入参数:&nbsp; 字符串<BR>&nbsp;&nbsp;&nbsp; ' 输出参数:&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' 返回值:&nbsp;&nbsp;&nbsp; 十进制数字<BR>&nbsp;&nbsp;&nbsp; '----------------------------------------------------------------&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Private Function getCFShi(ByVal strIn As String) As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim intCount As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim intJ As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intCount = 0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For intJ = 0 To 7<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If strIn.Substring(intJ, 1) = "1" Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Select Case intJ<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case 0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intCount = intCount + 128<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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p;&nbsp;&nbsp; getCFShi = intCount</P>
<P>&nbsp;&nbsp;&nbsp; End Function<BR>&nbsp;&nbsp;&nbsp; '----------------------------------------------------------------<BR>&nbsp;&nbsp;&nbsp; ' 过程名:&nbsp;&nbsp;&nbsp; getCF<BR>&nbsp;&nbsp;&nbsp; ' 功能:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 八位的二进制转换程十进制<BR>&nbsp;&nbsp;&nbsp; ' 输入参数:&nbsp; 字符串<BR>&nbsp;&nbsp;&nbsp; ' 输出参数:&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' 返回值:&nbsp;&nbsp;&nbsp; 十进制数字<BR>&nbsp;&nbsp;&nbsp; '----------------------------------------------------------------&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Private Function getCF(ByVal strIn As String) As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim intCount As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim intJ As Integer<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; intCount = 0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For intJ = 0 To 6<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If strIn.Substring(intJ, 1) = "1" Then<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Select Case intJ<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Case 0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp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nbsp; '----------------------------------------------------------------<BR>&nbsp;&nbsp;&nbsp; ' 过程名:&nbsp;&nbsp;&nbsp; getDate<BR>&nbsp;&nbsp;&nbsp; ' 功能:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 取得现在的日期，格式YYYY-MM-DD HH:MM:SS<BR>&nbsp;&nbsp;&nbsp; ' 输入参数:&nbsp; 无<BR>&nbsp;&nbsp;&nbsp; ' 输出参数:&nbsp; 无<BR>&nbsp;&nbsp;&nbsp; ' 返回值:&nbsp;&nbsp;&nbsp; 日期，字符串<BR>&nbsp;&nbsp;&nbsp; '----------------------------------------------------------------&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Public Function getDate() As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim strDate As String<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim strTmp As String</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strDate = Trim(Str(Year(Now)))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strTmp = "0" + Trim(Str(Month(Now)))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strDate = strDate + "-" + strTmp.Substring(strTmp.Length - 2, 2)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strTmp = "0" + Trim(Str(DateAndTime.Day(Now)))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strDate = strDate + "-" + strTmp.Substring(strTmp.Length - 2, 2)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strTmp = "0" + Trim(Str(DateAndTime.Hour(Now)))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strDate = strDate + " " + strTmp.Substring(strTmp.Length - 2, 2)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strTmp = "0" + Trim(Str(DateAndTime.Minute(Now)))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strDate = strDate + ":" + strTmp.Substring(strTmp.Length - 2, 2)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strTmp = "0" + Trim(Str(DateAndTime.Second(Now)))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strDate = strDate + ":" + strTmp.Substring(strTmp.Length - 2, 2)</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getDate = strDate<BR>&nbsp;&nbsp;&nbsp; End Function</P>
<P>End Module</P>
<P>&nbsp;</P><img src ="http://www.blogjava.net/Daniel2005/aggbug/20044.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/Daniel2005/" target="_blank">泌鲁沙夫</a> 2005-11-16 12:56 <a href="http://www.blogjava.net/Daniel2005/articles/20044.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>