资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

vb.net使用ini的简单介绍

VB.net2005中到底怎么读取ini文件

用API吧

靖江网站制作公司哪家好,找成都创新互联公司!从网页设计、网站建设、微信开发、APP开发、响应式网站等网站项目制作,到程序开发,运营维护。成都创新互联公司从2013年创立到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选成都创新互联公司

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

'读

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 WriteString As String, ByVal FileName As String) As Long

WriteINI = WritePrivateProfileString(Section, AppName, WriteString, FileName)

End Function

其中,Section是像[ip]那样的(填里面的就可以了),AppName是“=”前面的项名称,lpDefault是如果没有可用的值,就返回lpDefault,FileName是文件名,WriteString是要写入的值

你所希望的:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

MsgBox(GetINI("ip", "user_id", "", "D:\DataBase.ini"))

'返回sa

End Sub

vb.net 如何读取ini文件定义的ForeColor颜色值

你好,我不知道你是用什么方法保存的,不过.net里的color有一个方法是Color.FromArgb 你可以这么做,dim

c

as

color=richtextbox1.ForeColor dim

colorstring

as

string=c.ToArgb().ToString

colorstring就是颜色的值(字符串)再把colorstring保存到ini文件加载颜色的时候,从ini里读取colorstring 具体是:dim

RtextColor

as

color=Color.FromArgb(cint(colorstring))richtextbox1.ForeColor

=RtextColor

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的简单介绍
标题链接:http://cdkjz.cn/article/dogpshc.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220