vb.net 读取ini的所有值Dim s As String() = System.IO.File.ReadAllLines("t.ini") '文件
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(si1))
End If
Next
's(i).Substring(0, si)是变量名,s(i).Substring(si1)是值
vb.net读写ini文件问题以下是vb.netini读写我vb.netini读写的办法: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.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
其中,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 配置呢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】求个用VS2013读写INI的代码vb.net有自己的设置,不需要ini,在工程【属性】-【设置】中设置 。
——————
ini设置属性 。
'声明API函数
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 WriteINI(ByVal Section As String, ByVal AppName As String, ByVal lpDefault As String, ByVal FileName As String) As Long
Return WritePrivateProfileString(Section, AppName, lpDefault, FileName)
End Function
‘调用writeini函数存储属性 。
‘section为节点,也就是ini中带[]符号的节点文本
’APPname为存储的名称 , 即ini文件中等于符号前面的文本
’ipdefault为存储的属性,即等于符号右边的文本 。
‘filename为存储的ini文件地址,如d:\save.ini
————————
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 Function GetINI(ByVal Section As String, ByVal AppName As String, ByVal lpDefault As String, ByVal FileName As String) As String
Dim Str As String = ""
Str = LSet(Str, IniCount)
GetPrivateProfileString(Section, AppName, lpDefault, Str, Len(Str), FileName)
Return Microsoft.VisualBasic.Left(Str, InStr(Str, Chr(0)) - 1)
End Function
【vb.netini读写 vbnet读写文件】’调用getini函数
‘说明同上 。
关于vb.netini读写和vbnet读写文件的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。
推荐阅读
- java计算窗口程序代码,Java抢票程序代码
- 角色扮演表演游戏视频,角色扮演游戏活动方案
- 大象虚拟机,虚拟大师vmos1138
- 谷歌编程语言go怎么读 谷歌 开发语言
- 如何安装net4.8,如何安装net40
- 帮鳄鱼拔蛀牙体育游戏教案,给鳄鱼拔牙教案
- 土木工程招标代理服务平台,土木工程投标
- linux用户添加命令行 linux中添加用户命令
- 新媒体营销如何利用互联网思维,新媒体营销如何利用互联网思维