這個你可以用 api操作ini文件來實現(xiàn)。ini是windows系統(tǒng)的配置文件。
成都創(chuàng)新互聯(lián)公司專注于敦煌企業(yè)網(wǎng)站建設,成都響應式網(wǎng)站建設,商城網(wǎng)站建設。敦煌網(wǎng)站建設公司,為敦煌等地區(qū)提供建站服務。全流程定制網(wǎng)站,專業(yè)設計,全程項目跟蹤,成都創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務
'首先聲明這兩個api
Private Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
VB6.0
寫入:
Open "D:\123.txt" For Output As #1 '打開XXX路徑的XXX文件(雙引號里表示文件位置和文件名)
Print #1, Text1.Text '寫入Text1的Text內容
Close #1 '關閉
讀?。?/p>
Open "D:\123.txt" For Input As #1 '打開打開XXX路徑的XXX文件(雙引號里表示文件位置和文件名)
Do While Not EOF(1)
Line Input #1, s
Text1.Text = s
Loop 'Do...Loop表示循環(huán)讀取文件的內容,并讓Text1.Text=內容
Close #1 '關閉
VB.net中讀寫文件主要使用System.IO命名空間。
① 使用?File.ReadAllText 讀取
Dim s As String = System.IO.File.ReadAllText("C:\a.txt")
② 使用 StreamReader 讀取,注意編碼格式和寫入的編碼保持一致。
Dim sr As StreamReader = New StreamReader("C:\a.txt", System.Text.Encoding.UTF8)
Dim s As String = sr.ReadToEnd()
sr.Close()
1.使用文件來記錄,下次運行時讀取 .2.使用數(shù)據(jù)庫,可以考慮單機數(shù)據(jù)庫或網(wǎng)絡數(shù)據(jù)庫 3.如果數(shù)據(jù)量小,使用注冊表.
或者可以通過程序來保存:
set fs=createobject("scripting.filesystemobject")'創(chuàng)建文件操作對象
if fs.fileexists("C:\a.txt") then'如果C盤A.txt存在,那么讀取其內容
set txt=fs.opentextfile("C:\a.txt",forreading,true)
set txtn=txt.readall
else'
set txtf=fs.createtextfile("c:\a.txt",true)'創(chuàng)建C盤下的a.txt
do'無限循環(huán)
wscript.sleep 1000'延時一秒
txtf.write a.text'寫入文本框中內容
loop'循環(huán)結束
end if'判斷結束
都是用SQL語句完成的
寫入數(shù)據(jù)庫
strSQL="INTO TABLENAME (OPTION1,OPTIN2)VALUES(VALUE1,VALUE2)";
cmd.Connection = conn;
cmd.CommandText = strSQL;
cmd.Parameters.Add(paramrs[i]);
try
{
conn.Open();
}
catch(Exception ex)
{
throw ex;
}
finally
{
cmd.Parameters.Clear();
cmd.CommandText = null;
cmd.Dispose();
conn.Close();
}
讀取值
strSQL ="SELECT OPTION1,OPTION2 FROM TABLENAME";
cmd.CommandText = strSQL;
cmd.Connection = conn;
DataSet ds = new DataSet();
try
{
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
}
catch (Exception ex)
{
throw ex;
}
finally
{
cmd.Dispose();
conn.Close();
}
TextBox2.text = ds.Tables[0].rows[0][0].value.tostring();
文章題目:vbnet歷史數(shù)據(jù)存儲的簡單介紹
網(wǎng)站地址:http://chinadenli.net/article44/dsiehee.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供、網(wǎng)站維護、品牌網(wǎng)站建設、網(wǎng)站內鏈、網(wǎng)站收錄、品牌網(wǎng)站設計
聲明:本網(wǎng)站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)