求教如何在ini文件最后一行写入写入数据
[local]1[/local]求教
如图,在最后一行写入数据。[]里的序号是依次往下排的。
如:
[616]
类型=4
敏感词=0000000
禁言时间=
非常感谢版主发的代码亲测可用。
程序代码:
Dim BB As Integer
Private Sub Command1_Click()
Form_Load '刷新,载入最新数据
'添加记录
If Text2.Text = "" Then
MsgBox "请填写类型!"
Exit Sub
End If
If Text3.Text = "" Then
MsgBox "请填写敏感词!"
Exit Sub
End If
Open App.Path & "敏感词.ini" For Append As #1
Print #1, '换行
Print #1, Text1.Text
Print #1, "类型=" & Text2.Text
Print #1, "敏感词=" & Text3.Text
Print #1, "禁言时间=" & Text4.Text; ';代表不换行
Close #1
Text6.Text = ("添加成功:序号【" & Text1.Text & "】,类型【" & Text2.Text & "】,敏感词【" & Text3.Text & "】.添加时间:" & Now())'日志
Text5.Text = Text5.Text + Text6.Text & vbCrLf
Text5.SelStart = Len(Text5)
Form_Load '刷新,载入最新数据
'Unload Me
'写入数据.Show
End Sub
Private Sub Command2_Click()
Form_Load
End Sub
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = "4"
'Text3.Text = ""
Text4.Text = ""
Open App.Path & "敏感词.ini" For Input As #1
Do While Not EOF(1)
Input #1, AA
If Left(AA, 1) = "[" Then
BB = Val(Right(AA, Len(AA) - 1))
End If
Loop
Close #1
BB = BB + 1
Text1.Text = "[" & BB & "]"
End Sub
[此贴子已经被作者于2020-7-14 10:32编辑过]