谢谢代码。
谢谢!!!!!!
谢谢!!!!!!
解决方案 »
- inet 问题求助
- VB SENDMESSAGE调用,向另一个应用程序发送。在SPY里看到坐标总是不对。
- 我的文件传输(FTP)程序问题
- 如何使outlook执行收邮件命令?
- 各为api高手看过来!
- 请问在vb中新建了一个工程以后,要怎样设置才能把from1窗口变成MDIForm?? 多谢了 !!!
- 求救一个简单问题,怎么处理字符串中的"字符
- 急!急!!实时错误 ’2147024770 (8007007e)’自动化错误
- 1英寸=1440twip,1毫米=56.47twip,那一个字符等于多少twip
- 吐血推荐: Move and Resize Controls at Run-Time (Like the VB IDE).
- 怎样用ADO访问MDB数据库?在线等待
- 请问在VB6中,如何点击一个按钮,让它起到类似网页中mailto的作用?或超链接
先用FSO把ini文件读入。
dim objRegExp as object
Set objRegExp=new RegExp
objRegExp.IgnoreCase =true
objRegExp.Global=Trueobj
RegExp.pattern="(\[)(.+?)(\])"
然后用$2代替[]中间的部分。
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As LongFunction ReadConfig(AppName As String, StrKey As String) As String
Dim StrBuff As String
Dim Xpos As Integer
StrBuff = String(255, Chr(0))
GetPrivateProfileString AppName, StrKey, "ERROR", StrBuff, 255, AddBackSlash(App.path) & "config.ini"
ReadConfig = Trim(Left(StrBuff, InStr(StrBuff, Chr(0)) - 1))
End FunctionFunction WriteConfig(AppName As String, StrKey As String, StrValue As String) As String
WritePrivateProfileString AppName, StrKey, StrValue, AddBackSlash(App.path) & "config.ini"
End FunctionFunction AddBackSlash(lzPath As String) As String
If Right(lzPath, 1) <> "\" Then AddBackSlash = lzPath & "\" Else AddBackSlash = lzPath
End Function
'Renames a section in a given INI file.
'Function returns 1 if successful and 0 if unsuccessful
Dim TopKeys As String
Dim BotKeys As String
Dim Looper As Integer
Dim InputData As String
Dim InZone As Boolean
Dim Key1 As String, Key2 As String
If Dir(FileName) = "" Then MsgBox FileName & " not found.", vbCritical, "File Not Found": Exit Function
If Not SectionExists(FileName, SectionName) Then MsgBox "Section, " & SectionName & ", Not Found. ~(RenameSection)" & vbCrLf & "Verify spelling and capitilization is correct. Case-sensative.", vbInformation, "Section Not Found.": RenameSection = 0: Exit Function
If SectionExists(FileName, NewSectionName) Then MsgBox NewSectionName & " allready exists. ~(RenameSection)", vbInformation, "Duplicate Section": RenameSection = 0: Exit Function
Open FileName For Input As #4Do While Not EOF(4)
Line Input #4, InputData
If InZone Then
If BotKeys = "" Then BotKeys = InputData Else BotKeys = BotKeys & vbCrLf & InputData
If EOF(4) Then
Close #4
Kill FileName
Open FileName For Append As #5
If TopKeys <> "" Then Print #5, TopKeys
Print #5, "[" & NewSectionName & "]" & vbCrLf & BotKeys
Close #5
RenameSection = 1
Exit Function
End If
Else
If InputData = "[" & SectionName & "]" Then
InZone = True
Else
If TopKeys = "" Then TopKeys = InputData Else TopKeys = TopKeys & vbCrLf & InputData
End If
End If
Loop
Close #4
End Function
有多少个section,也就是有多少个[];
每个section里的字符串[。],是什么,能写下来。对具体section中key的读写已经没有问题。请再看看!
谢谢!!!
谢谢你。
对文本文件的操作,
我是速成新手
谢谢