vb.net读写ini文件问题以下是vb.net使用ini我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," ")
【关于vb.net使用ini的信息】GetPrivateProfileString("存储", "账号", s, s.Length, Application.StartupPath"\song.ini")
textbox1 =s
VB.net2005中到底怎么读取ini文件用API吧
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
其中vb.net使用ini,Section是像[ip]那样的(填里面的就可以vb.net使用ini了)vb.net使用ini,AppName是“=”前面的项名称,lpDefault是如果没有可用的值,就返回lpDefault,FileName是文件名,WriteString是要写入的值
vb.net使用ini你所希望的:
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操作名字有规律,就可以for循环 。
名字没有规律,可以想办法让他有规律 , 一种方法是设置包含所有节名称的string数组 , 再循环 。
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 配置呢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("配置设置已经成功vb.net使用ini!vb.net使用ini!vb.net使用ini!vb.net使用ini!")
Catch ex As Exception
MsgBox("错误?。。。?)
End Try
End Sub
vb.net使用ini的介绍就聊到这里吧 , 感谢你花时间阅读本站内容,更多关于、vb.net使用ini的信息别忘了在本站进行查找喔 。
推荐阅读
- 使命召唤10下载,使命召唤10下载中文单机版
- 如何确定营销营销沟通目标,营销策划中,如何确定有效的营销目标?
- dj网盘下载,dj歌曲百度云盘下载
- vb.net! vbnet和vba的区别
- 营销模式如何赚钱,营销模式怎么说
- 及时战略游戏操作,战略及时性游戏
- 关于postgresql9.4.11下载的信息
- php读取数据库数量 php获取数据库记录
- python怎么用turtle花国旗,python画国旗