十年網(wǎng)站開發(fā)經(jīng)驗(yàn) + 多家企業(yè)客戶 + 靠譜的建站團(tuán)隊(duì)
量身定制 + 運(yùn)營(yíng)維護(hù)+專業(yè)推廣+無(wú)憂售后,網(wǎng)站問(wèn)題一站解決
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來(lái)自于我們對(duì)這個(gè)行業(yè)的熱愛(ài)。我們立志把好的技術(shù)通過(guò)有效、簡(jiǎn)單的方式提供給客戶,將通過(guò)不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長(zhǎng)期合作伙伴,公司提供的服務(wù)項(xiàng)目有:主機(jī)域名、虛擬空間、營(yíng)銷軟件、網(wǎng)站建設(shè)、紅河哈尼網(wǎng)站維護(hù)、網(wǎng)站推廣。
System.IO.Directory.CreateDirectory("C:\我的文件夾") '創(chuàng)建目錄,路徑就自己改吧,如果路徑存在,就沒(méi)必要?jiǎng)?chuàng)建了
System.IO.File.Create("C:\我的文件夾\我的文件.doc") '在指定目錄下創(chuàng)建word文檔
End Sub
很簡(jiǎn)單,用字符串查找函數(shù)就可以實(shí)現(xiàn)了。
當(dāng)在StrB查找到StrA字符串時(shí),返回肯定是非0的數(shù),值就是True,找不到為0或者-1,值就是Flase
比如:
Dim StrA As String = "Time is Limited"
Dim StrB As String = "Time"
Dim Stu As Boolean= InStr(StrA, StrB)
這運(yùn)行段代碼,Stu值就是True了。
我覺(jué)得這樣最簡(jiǎn)單有效。
設(shè)計(jì)一個(gè)窗口,添加一個(gè)名為textBox1的System.Windows.Forms.TextBox,
添加一個(gè)名為button1的System.Windows.Forms.Button。
為button1的單擊事件添加如下處理函數(shù):
Sub Button1Click(sender As Object, e As EventArgs)
'f是你的文本文件的文件名
Const f As String="t.txt"
Dim sw As System.IO.StreamWriter=Nothing
Try
If Not System.IO.File.Exists(f) Then
sw=System.IO.File.CreateText(f)
Else
sw=New System.IO.StreamWriter(f,True)
End If
sw.WriteLine(textBox1.Text)
Finally
If sw IsNot Nothing Then
sw.close()
End If
End Try
End Sub
按你說(shuō)的方式,需要用到鉤子
建議你用File類進(jìn)行操作,保存為TXT文件
祝好運(yùn),望采納
Dim SaveFileDialog1 As New SaveFileDialog()
'創(chuàng)建一個(gè)保存對(duì)話框
SaveFileDialog1.Filter = "txt files (*.txt)|*.txt"
'設(shè)置
擴(kuò)展名
If SaveFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
'如果確定保存
My.Computer.
FileSystem
.WriteAllText(SaveFileDialog1.Filename, Textbox1.Text,False)
'保存文本,False表示不追加文本,直接覆蓋其內(nèi)容
End If
舉個(gè)例子:
先引入命名空間:
Imports
System.IOImports
System.Security.AccessControl
代碼:
Dim
sec
As
DirectorySecurity
=
New
DirectorySecurityDim
rule
As
FileSystemAccessRule
=
New
FileSystemAccessRule("Administrator",
FileSystemRights.Delete,
AccessControlType.Allow)sec.AddAccessRule(rule)Directory.CreateDirectory("C:\test",
sec)
這段代碼就是以
Administrator
帳戶
在
C:\
創(chuàng)建
test
文件夾。