『壹』 vb.net 配置文件怎麼寫
簡單的辦法就是:文本文件或者資料庫文件。
『貳』 vb.net都可以讀取哪些格式的文件
基本都能讀取,文本類型的完全沒問題,高級文本比如DOC等文檔需要一些控制項、演算法支持。理論上來說全都支持,但是如何訪問就要看技術。參數等信息一般保存在配置文件、XML文件、注冊表中 追問: 配置文件是什麼格式的文件 回答: 是以INI為後綴名,但是是TXT 文件格式 ,文 本格 式,可以用記事本打開。於普通文本格式不同的是,INI裡面的信息都是有一定規律的存放。便於再次讀寫
『叄』 VB.NET2010讀取INI配置文件問題
設計一個讀取函數
說明:在引用的面頁中要先引用 Imports System.IO
Function sdGetIniInfo(ByVal iniFile As String, ByVal iniSection As String) As String
If Not File.Exists(iniFile) Then
Return "文件 " & iniFile & " 未找到,請確認路徑和文件名是否正確!"
Exit Function
End If
Dim iniRead As New StreamReader(iniFile) Dim iniStr As String = iniRead.ReadToEnd
Dim i As Integer
Dim cLine As Integer
Dim noSec As Boolean = False
Dim getValue As String = ""
Dim cLst
cLst = iniStr.Split(Chr(13)) cLine = UBound(cLst)
For i = 0 To cLine
If cLst(i).indexof("=") > 0 Then
If cLst(i).split("=")(0).trim() = iniSection Then
noSec = True
getValue = cLst(i).split("=")(1).trim()
Exit For
End If
End If
Next
If noSec = True Then
Return getValue
Else
Return "沒有找到 " & iniSection & " 的設置信息!"
End If
End Function
==========================================
TEXT1=sdGetIniInfo(路徑,「Name」)
其他類似
其實,無論ini和xml都是文本文件,只是帶了一些格式,或者叫數據結構吧,歸根到底都是用文件操作來實現,一些函數也只不過是封裝好了的文件讀寫操作而已!
這不是api,就是自己寫個函數!
『肆』 vb.net2008讀取INT配置文件
總體思路,當文本文件讀,system中有一個io.file對象,可以用readalltext讀取txt文件,讀完了過後再用string.split函數一個個進行解析,賦值。不過真沒聽說過INT配置文件,不是INI嗎?
『伍』 VB中配置文件怎麼用
vb讀寫ini 這個方法在vb.net自帶都有 你可以在vb.net創建一個ini 在.net叫config 主要方法 思想和 讀寫 .txt文件一樣 對字元串操作。
『陸』 求大神指點 vb.net 怎麼讀 ini 配置呢
VB.NET讀寫INI配置文件
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim path As String
path = Application.StartupPath + "\Send.ini"
TextBox1.Text = GetINI("Send", "Send1", "", path)
TextBox2.Text = GetINI("Send", "Send2", "", path)
Dim IsSms As Integer = GetINI("Send", "IsSms", "", path)
If (IsSms = 1) Then
Me.RadioButton1.Checked = True
ElseIf (IsSms = 0) Then
Me.RadioButton2.Checked = True
End If
End Sub
Public Function GetINI(ByVal Section As String, ByVal AppName As String, ByVal lpDefault As String, ByVal FileName As String) As String
Dim Str As String = LSet(Str, 256)
GetPrivateProfileString(Section, AppName, lpDefault, Str, Len(Str), FileName)
Return Microsoft.VisualBasic.Left(Str, InStr(Str, Chr(0)) - 1)
End Function
Public Function WriteINI(ByVal Section As String, ByVal AppName As String, ByVal lpDefault As String, ByVal FileName As String) As Long
WriteINI = WritePrivateProfileString(Section, AppName, lpDefault, FileName)
End Function
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Int32, ByVal lpFileName As String) As Int32
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Int32
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim path As String
path = Application.StartupPath + "\Send.ini"
WriteINI("Send", "Send1", TextBox1.Text, path)
WriteINI("Send", "Send2", TextBox2.Text, path)
If (Me.RadioButton1.Checked = True) Then
WriteINI("Send", "IsSms", 1, path)
ElseIf (Me.RadioButton2.Checked = True) Then
WriteINI("Send", "IsSms", 0, path)
End If
MsgBox("配置設置已經成功!!!!")
Catch ex As Exception
MsgBox("錯誤!!!!")
End Try
End Sub
『柒』 vb.net中,讀取和寫入文件
寫入:Dim sr As New IO.StreamWriter(Application.StartupPath & "/寫入的文本.txt")
sr.WriteLine("寫入的內容") sr.Close()讀取:If (File.Exists(Application.StartupPath & "/msg.txt")) Then
Dim fm As New IO.FileStream(Application.StartupPath & "/讀取的文本.txt", FileMode.Open)
Dim sr As IO.StreamReader = New IO.StreamReader(fm)
Do While sr.Peek() >= 0
TextBox1.Text = sr.ReadLine() (讀取文本到文本框)
Loop end if
『捌』 vb.net 讀取配置文件,求大神幫忙!急急急!!!!!
element.value
『玖』 請教在VB.net中如何將數據寫入txt文件、再從txt文件讀出
寫入:
Open "D:\123.txt" For Output As #1 '打開XXX路徑的XXX文件(雙引號里表示文件位置和文件名)
Print #1, Text1.Text '寫入Text1的Text內容
Close #1 '關閉版
讀取:權
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表示循環讀取文件的內容,並讓Text1.Text=內容
Close #1 '關閉
『拾』 vb.net 2.0 如何用Configuration.ConfigurationSettings.AppSettings讀取配置文件中的內容
使用ConfigurationSettings.AppSetting讀取,如下例
Imports System.Configuration
Private ReadOnly db As String = ConfigurationSettings.AppSettings("DB")