十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
名字有规律,就可以for循环。
创新互联建站-专业网站定制、快速模板网站建设、高性价比官渡网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式官渡网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖官渡地区。费用合理售后完善,10多年实体公司更值得信赖。
名字没有规律,可以想办法让他有规律,一种方法是设置包含所有节名称的string数组,再循环。
设计功能
说明:第一个参考页导入了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读写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读写ini 这个方法在vb.net自带都有 你可以在vb.net创建一个ini 在.net叫config 主要方法 思想和 读写 .txt文件一样 对字符串操作。
这和ini文件有什么关系?要保存运行时数据,可使用app.config或xml文件或注册表或数据库,ini文件已经被淘汰