快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

vb.net读取ini vb net

vb.net 读取ini的所有值

Dim s As String() = System.IO.File.ReadAllLines("t.ini") '文件

成都创新互联公司拥有十多年成都网站建设工作经验,为各大企业提供成都网站建设、成都网站制作服务,对于网页设计、PC网站建设(电脑版网站建设)、重庆APP开发公司、wap网站建设(手机版网站建设)、程序开发、网站优化(SEO优化)、微网站、域名注册等,凭借多年来在互联网的打拼,我们在互联网网站建设行业积累了很多网站制作、网站设计、网络营销经验,集策划、开发、设计、营销、管理等网站化运作于一体,具备承接各种规模类型的网站建设项目的能力。

For i As Integer = 0 To s.Length - 1

Dim si As Integer = s(i).IndexOf("=")

If si  -1 Then

ListBox1.Items.Add(s(i).Substring(0, si)  " = "  s(i).Substring(si + 1))

End If

Next

's(i).Substring(0, si)是变量名,s(i).Substring(si + 1)是值

vb.net读写ini文件问题

以下是我的办法:OK!

Public 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 Integer, ByVal lpFileName As String) As Integer

Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String) As Integer

写:

WritePrivateProfileString("存储", "账号", textbox1, Application.StartupPath "\song.ini")

读:

dim s as string

s = string(255," ")

GetPrivateProfileString("存储", "账号", s, s.Length, Application.StartupPath + "\song.ini")

textbox1 =s

求大神指点 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读取ini vb net
文章位置:http://6mz.cn/article/hjgcoj.html

其他资讯