vb.net读取配置文件,vb 读取配置文件

求大神指点 vb.net 怎么读 ini 配置呢

VB.NET读写INI配置文件

发展壮大离不开广大客户长期以来的信赖与支持,我们将始终秉承“诚信为本、服务至上”的服务理念,坚持“二合一”的优良服务模式,真诚服务每家企业,认真做好每个细节,不断完善自我,成就企业,实现共赢。行业涉及小搅拌车等,在成都网站建设营销型网站建设、WAP手机网站、VI设计、软件开发等项目上具有丰富的设计经验。

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.NET2010读取INI配置文件问题?

设计功能

说明:第一个参考页导入了System.IO

功能sdGetIniInfo(字符串的BYVAL iniSection的字符串,BYVAL INIFILE),如果该字符串/ File.Exists (INIFILE返回的“文件”INIFILE的的)

,而“未找到,以确保路径和文件名是否正确!”如果

黑暗iniRead

昏暗的iniStr新的StreamReader(INIFILE),的字符串iniRead.ReadToEnd

朦胧朦胧的整数

最后的出口,克莱因整数

昏暗的NOSEC布尔=假

作为一个字符的字符串昏暗的getValue“

黑暗的壁橱

衣柜iniStr.Split(CHR(13 ))CLINE = UBOUND功能的(CLST)

= 0 CLINE

衣柜(I)的indexOf(“=”) 0,

衣柜(I)分裂(“=”) (0)TRIM()= iniSection

NOSEC =

的getValue = CLST(I)分裂(“=”;)(1)修剪()

BR /退出

最后,如果

如果NOSEC = TRUE

返回的getValue BR /

的安装信息没有找到“iniSection!”

功能

====如果=================== ===================

TEXT1 = sdGetIniInfo(路径,“名称”)

事实上,无论是ini文本文件XML只使用一定的格式,或所谓的数据结构,在最后的分析中,实现的文件操作的功能只是一个包文件的读取和写入操作。

是不是写一个函数的API!

vb.net 2.0 如何用Configuration.ConfigurationSettings.AppSettings读取配置文件中的内容?

使用ConfigurationSettings.AppSetting读取,如下例

Imports System.Configuration

Private ReadOnly db As String = ConfigurationSettings.AppSettings("DB")

vb.net 关于配置文件和修改richtextbox字体

跟配置文件没有关系。

只是要求把你更改后的字体大小保存到一个文件内(文本或APP.CONFIG)

然后读取出来

如果是配置文件的话

参考

System.Configuration.ConfigurationManager


标题名称:vb.net读取配置文件,vb 读取配置文件
网页URL:http://pwwzsj.com/article/dsggsio.html