請你使用timer元件,配合下列副函數,如"wait 5"就是等待5秒
Private Sub Wait(iSec As Long)
Dim iTimer As Long
iTimer = Timer
Do Until Timer - iTimer >= iSec
DoEvents
Loop
End Sub
2015年2月9日 星期一
2014年6月30日 星期一
文字檔開啟
一、直接使用File opentext的方式
Dim sr As StreamReader = File.OpenText("utf.txt")
二、使用FileInfo的方法
Dim file1 As FileInfo = New FileInfo("b12.txt")
Dim sr As StreamReader = file1.OpenText()
Dim file1 As FileInfo = New FileInfo("b12.txt")
Dim sr As StreamReader = file1.OpenText()
三、使用 File 的 OpenText 或 FileInfo 的 OpenText 預設都以 UTF-8 編碼方式開啟檔案,若遇上文字檔本身並非UTF存檔,會有亂碼產生。若需指定編碼開啟,需使用如下:
Dim sr As StreamReader = My.Computer.FileSystem.OpenTextFileReader("b12.txt", System.Text.Encoding.Default)
Dim sr As StreamReader = My.Computer.FileSystem.OpenTextFileReader("b12.txt", System.Text.Encoding.Default)
Default: 是使用文預設的編碼方式開啟
2014年6月28日 星期六
判斷路徑資料夾是否存在及建立資料夾
VB.NET
判別路徑資料夾是否存在:
If Not IO.Directory.Exists("Path+資料夾名稱") Then
'如不存在,建立資料夾
IO.Directory.CreateDirectory("Path+資料夾名稱")
End If
判別路徑檔案是否存在:
System.IO.File.Exists("Path+FileName")
http://programlanguagebymingze.blogspot.tw/2012/10/vbnet.html
判別路徑資料夾是否存在:
If Not IO.Directory.Exists("Path+資料夾名稱") Then
'如不存在,建立資料夾
IO.Directory.CreateDirectory("Path+資料夾名稱")
End If
判別路徑檔案是否存在:
System.IO.File.Exists("Path+FileName")
http://programlanguagebymingze.blogspot.tw/2012/10/vbnet.html
2014年6月13日 星期五
模擬鍵盤(文字輸入 自動輸入 打字)
| 1 | Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) |
| 2 | '送出CTRL+C(複製) |
| 3 | 'SendKeys.Send("^C") |
| 4 | '送出CTRL+X(剪下) |
| 5 | 'SendKeys.Send("^X") |
| 6 | '送出CTRL+V(貼上) |
| 7 | SendKeys.Send("^V") |
| 8 | End Sub |
| 1 | Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) |
| 2 | If Me.DataGridView1.SelectedCells.Count > 0 Then |
| 3 | '送出CTRL+C(複製) |
| 4 | 'SendKeys.Send("^C") |
| 5 | End If |
| 6 | TextBox1.Focus() |
| 7 | '送出CTRL+V(貼上) |
| 8 | SendKeys.Send("^V") |
| 9 | End Sub |
http://www.blueshop.com.tw/board/show.asp?subcde=BRD20110708100140U3F
複製剪貼簿文字(複製、貼上 Ctrl C、Ctrl V)
.net平台中剪貼簿(ClipBoard)被拉到My.Computer.Clipboard下
不過實際存取時,可以省略 My.Computer
不過實際存取時,可以省略 My.Computer
'記事本複製功能 Clipboard.Clear() Clipboard.SetText(TextBox1.SelectedText) '記事本剪下功能 Clipboard.Clear() Clipboard.SetText(TextBox1.SelectedText) Textbox1.SelectedText = "" '記事本貼上功能 TextBox1.SelectedText = Clipboard.GetText()
PS SelectedText 同 VB6 的SelText
http://jeremy.ssinrc.org/?p=65
2014年6月4日 星期三
VB.net Unicode 轉 Big5 "OOOO;" 網頁亂碼 瀏覽器
'將網頁的Unicode 轉 Big5 (【)
For i = 0 To strSubTitle.Length - 1
Dim tmpS As String = strSubTitle(i)
tmpS = Replace(tmpS, "&#", "")
strNewTitle = strNewTitle & ChrW(tmpS)
Next
strTitle = strNewTitle
tbxTitle.Text = strTitle
For i = 0 To strSubTitle.Length - 1
Dim tmpS As String = strSubTitle(i)
tmpS = Replace(tmpS, "&#", "")
strNewTitle = strNewTitle & ChrW(tmpS)
Next
strTitle = strNewTitle
tbxTitle.Text = strTitle
2014年6月3日 星期二
VB.net 字串格式 Format
Format是VB.Net中很好用,不需死記參數,很人性化的格式化Function,舉例:
123456789 (三位一撇千分位)
Format(123456789, "###,###") OutPut ; 123,456,789
0.2666666 (小數點後兩位,四捨五入,並加上%)
Format(0.2666666,"0.00%") OutPut : 26.67%
千分位,小數點捨去
Format(Val(strValue.ToString), "###,##0")
訂閱:
文章 (Atom)