當前位置:編程學習大全網 - 網站源碼 - 求VB源碼(能用即再送30分)!

求VB源碼(能用即再送30分)!

'dlgCommonDialog為對話框控件名 部件中引用micr. common dialog control 6.0 可以使用該控件

'cmdChose為按鈕

'text1為文本框,此查詢區分大小寫

Private Sub cmdChose_Click()

With dlgCommonDialog

.DialogTitle = "打開到XML文件:"

.CancelError = False

.Filter = "文本文件(*.txt)|*.txt|所有格式(*.*)|*.*"

.InitDir = App.Path

.FileName = ""

.ShowOpen

' .DefaultExt

If Len(.FileName) = 0 Then

Exit Sub

End If

TxtFilePath.Text = .FileName

Dim aline As String

Open .FileName For Binary As #1

aline = String((LOF(1)), Chr(0))

Get #1, , aline

Close #1

'註意查找時區分大小寫

If InStr(aline, Text1.Text) > 0 Then

'說明包含

MsgBox "找到該字符串"

Dim cmdstr As String

'如果用richtext打開該文件,可以定位位置

cmdstr = "notepad.exe " & .FileName

Shell cmdstr

Else

MsgBox "未找到該字符串"

End If

End With

End Sub

  • 上一篇:使用c# 來寫壹個很簡單的相冊瀏覽器,
  • 下一篇:如何進入花貓壁紙的網絡名人區?
  • copyright 2024編程學習大全網