VB可以用任何格式保存文件數(shù)據(jù)不僅僅是注冊表\XML\INI
我們提供的服務(wù)有:網(wǎng)站設(shè)計制作、成都網(wǎng)站設(shè)計、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認證、東山ssl等。為近千家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的東山網(wǎng)站制作公司
甚至于未知的格式。我教你命令:
open "C:\setup.safe" for output as #1
print #1,"object"
close #1
其中setup.safe就是一個文件,后綴為.safe,當然可以改成.dat包括其他任何后綴.
object就是你要寫入setup.safe的內(nèi)容.
這個你可以用 api操作ini文件來實現(xiàn)。ini是windows系統(tǒng)的配置文件。
'首先聲明這兩個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
都是用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();