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文件定义的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.NET2010读取INI配置文件问题?设计功能
说明:第一个参考页导入了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 = https://www.04ip.com/post/CLST(I)分裂(“=”;)(1)修剪()
BR /退出
最后,如果
如果NOSEC = TRUE
返回的getValue BR /
的安装信息没有找到“iniSection!”
功能
【vb.netini文件 vbnet ini文件】====如果=================== ===================
TEXT1 = sdGetIniInfo(路径 , “名称”)
事实上 , 无论是ini文本文件XML只使用一定的格式 , 或所谓的数据结构 , 在最后的分析中 , 实现的文件操作的功能只是一个包文件的读取和写入操作 。
是不是写一个函数的API!
VB.NET怎么删除INI文件里的一个字段或键值?1,对于INI文件,可以当做像TXT文件一样来进行读取和写入 。
2,先把整个文件度出来,然后找到相应行删除(抛弃)以后,再重新写入文件 。
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyStr As String = ""
Dim AllStr As String = ""
'获取一个可用的文件号
Dim MyFileNum As Integer = FreeFile()
'打开指定的文件,进行读取操作
FileOpen(MyFileNum, "C:\My.ini", OpenMode.Input)
Do While Not EOF(MyFileNum)
'读取一行
MyStr = LineInput(MyFileNum)
If MyStr"b=2" Then
If AllStr = "" Then
AllStr = AllStrMyStr
Else
AllStr = AllStrvbCrLfMyStr
End If
End If
Loop
FileClose(MyFileNum)'关闭文件
'写文件
Dim MyStream As New System.IO.FileStream("C:\My.ini", IO.FileMode.Create)
Dim MyWriter As New System.IO.StreamWriter(MyStream, System.Text.Encoding.UTF8)
MyWriter.WriteLine(AllStr)
MyWriter.Flush()
MyWriter.Close()
MyStream.Close()
End Sub
End Class
求大神指点 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.netini文件的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于vbnet ini文件、vb.netini文件的信息别忘了在本站进行查找喔 。
推荐阅读
- java代码中的算法代码,java代码加密
- excel误删除如何恢复,excel误删除恢复文件
- 那个网络游戏赚钱,什么网络游戏可以搬砖赚钱
- php动态获取数据库数据 php怎么从数据库读取数据
- java为什么要代码,java为什么需要编译
- 什么是真高清视频通话的简单介绍
- 用无人机吃鸡直播怎么弄,怎么用无人机开直播
- java反三角函数代码 java math三角函数
- 董明珠直播是在什么平台,董明珠直播是在什么平台上