發表文章

目前顯示的是 3月, 2011的文章

瞭解程式執行時間

轉貼文章:http://tfeng.org/?p=1215 逐風者 這是 .net framework 2.0 新增的類別,可以讓你知道您得程式耗費多少時間,有助於優化自己得程式! ? View Code VB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 VB.net Code:   Dim sw As New System.Diagnostics.Stopwatch() Dim num As Long = 0 sw.Reset() sw = Stopwatch.StartNew() '要測速的程式碼放這裡 sw. Stop () Dim ms As Long = sw.ElapsedMilliseconds Debug. Print ( "花費 {0} 毫秒" , ms) Dim el As TimeSpan = sw.Elapsed Debug. Print ( "花費 {0} " , el)   範例:(檢查 do ...... loop 花的時間) Dim sw As New System.Diagnostics.Stopwatch() Dim num As Long = 0 sw.Reset() sw = Stopwatch.StartNew() Do unitle x>100 x += 1 loop sw. Stop () Dim ms As Long = sw.ElapsedMilliseconds Debug. Print ( "花費 {0} 毫秒" , ms) Dim el As TimeSpan = sw.Elapsed Debug. Print ( "花費 {0} " , el) C# Code: ? View Code CSHAPE 1 2 3 4 5 6 7 8 9 10 11 12 using System.Diagnostics; //------------------------------------------- Stopwatch sw = new Stopwat

[VB.Net]讀取拖曳檔案的路徑

圖片
轉貼文章:六度空間 http://jeremy.tfeng.org/?p=502 此程式碼可讀取到使用者拖曳到視窗裡的檔案路徑 請開啟一個Windows Form 後,分別在以下事件加入程式碼: (Form1_Load,Form1_DragDrop,Form1_DragEnter) Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.AllowDrop = True End Sub Private Sub Form1_DragDrop(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragDrop Dim DragFilePath As String = CType(e.Data.GetData("FileNameW"), Array).GetValue(0) MsgBox(DragFilePath) End Sub Private Sub Form1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragEnter e.Effect = DragDropEffects.All End Sub    Private Sub Form1_DragEnter(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragEnter        e.Effect = DragDropEffects.All    End Sub