vb 怎麼对ini文件 中Section 值修改?

文件结构如下,要修改[bbbb]为[cccc][aaaa]a1=1a2=2[bbbb]b1=1b2=2... 文件结构如下,要修改[bbbb]为[cccc]
[aaaa]
a1=1
a2=2

[bbbb]
b1=1
b2=2
展开
 我来答
让部分人看到未来
2013-09-15 · 超过12用户采纳过TA的回答
知道答主
回答量:88
采纳率:0%
帮助的人:21.7万
展开全部
方法:建立一工程,随便命名

控件 8个command,2个text ,

代码如下:

'API声明

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Declare Function GetPrivateProfileString Lib "Kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, lpKeyName As Any, ByVal lpDefault As String, ByVal lpRetunedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Declare Function WritePrivateProfileString Lib "Kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lplFileName As String) As Long

‘变量声明

Private r As Long
Private entry As String
Private iniPath As String

’定义

Function GetFromINI(AppName As String, KeyName As String, FileName As String) As String
Dim RetStr As String
RetStr = String(255, Chr(0))
GetFromINI = Left(RetStr, GetPrivateProfileString(AppName, ByVal KeyName, "", RetStr, Len(RetStr), FileName))
End Function

Private Sub Command1_Click()
Text1.Text = GetFromINI("zc", "ID", iniPath)
End Sub

Private Sub Command8_Click()
End
End Sub

Private Sub Command2_Click()
Text2.Text = GetFromINI("yh", "NAME", iniPath)
End Sub

Private Sub Command4_Click()
entry$ = Text1.Text
r = WritePrivateProfileString("zc", "ID", entry, iniPath)
If r <> 1 Then MsgBox "error!"
End Sub

Private Sub Command5_Click()
entry = Text2.Text
r = WritePrivateProfileString("yh", "NAME", entry, iniPath)
If r <> 1 Then MsgBox "error!"
End Sub

Private Sub Command7_Click()
Text1.Text = GetFromINI("zc", "ID", iniPath)
Text2.Text = GetFromINI("yh", "NAME", iniPath)
End Sub

Private Sub Command3_Click()
Command4_Click
Command5_Click
End Sub

Private Sub Command6_Click()
Text1.Text = ""
Text2.Text = ""
End Sub

Private Sub Form_Load()
iniPath$ = App.Path + "\GLKJ.ini"
Command7_Click
End Sub
匿名用户
2013-09-15
展开全部
百度一下读写INI,到处都是
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式