精华内容
下载资源
问答
  • VB读写ini文件
    2014-05-30 15:29:00

    http://blog.csdn.net/surro/article/details/1751905

    转载于:https://www.cnblogs.com/tianshuilv/p/3761188.html

    更多相关内容
  • 内容索引:VB源码,文件操作,INI VB生成INI文件的一个例子,可按要求将内容写入到INI文件中,并读取这些内容。友情提示:测试文件test.ini放在C盘下,参数一: Section Name。  参数二: 于.ini中的项目。  参数三...
  • 速度比windows的API要快很多,数据量大的情况下对比更明显。代码中有两种方法的比较并记录。
  • NI文件的读取 INI文件是Windows系统最早采用的文本文件格式,在C:驱动器根目录中往往都会存在着一个隐藏的...一个ini文件读写类的设计和实现 bichengguibichenggui 决定自己写一个ini读写类,希望对大家能有所帮助。
  • vb读写ini文件

    2018-10-22 16:29:25
    Public Sub WriteIni(appName As String, keyName As String, valueNew As String) Dim x As Long Dim strIniFile As String If Right(App.Path, 1) = "\" Then strIniFile = App.Path & mc_strIniFileName ...

    代码最开头加入这个:
    Private Declare Function GetPrivateProfileString Lib “kernel32” Alias “GetPrivateProfileStringA” ( _
    ByVal lpApplicationName As String, _
    ByVal lpKeyName As Any, _
    ByVal lpDefault As String, _
    ByVal lpReturnedString 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 lpFileName As String) As Long

    Private Const mc_strIniFileName As String = “MyIni.ini”

    然后添加这个:

    Public Function GetIni(appName As String, keyName As String) As String
    Dim strDefault As String
    Dim lngBuffLen As Long
    Dim strResu As String
    Dim x As Long
    Dim strIniFile As String

    If Right(App.Path, 1) = "\" Then
        strIniFile = App.Path & mc_strIniFileName
    Else
        strIniFile = App.Path & "\" & mc_strIniFileName
    End If
      
    strResu = String(1025, vbNullChar): lngBuffLen = 1025
    strDefault = ""
    x = GetPrivateProfileString(appName, keyName, strDefault, strResu, lngBuffLen, strIniFile)
    Debug.Print x
    Debug.Print strResu
    GetIni = Left(strResu, x)      
    

    End Function

    Public Sub WriteIni(appName As String, keyName As String, valueNew As String)
    Dim x As Long
    Dim strIniFile As String

    If Right(App.Path, 1) = "\" Then
        strIniFile = App.Path & mc_strIniFileName
    Else
        strIniFile = App.Path & "\" & mc_strIniFileName
    End If
    x = WritePrivateProfileString(appName, keyName, valueNew, strIniFile)
    Debug.Print x
    

    End Sub

    然后一个button测试下:
    Private Sub Command3_Click()
    Dim strRet As String
    strRet = GetIni(“AAA”, “BBB”)

    MsgBox "读出为:" & strRet
    

    End Sub

    展开全文
  • GetPrivateProfileString "Setting", In_Key, "", GetStr, 256, App.Path & "\SourceDB.ini" GetStr = VBA.Replace(GetStr, VBA.Chr(0), "") If GetStr = "1" Then GetIniTF = True GetStr = "" Else GoTo ...
  • VB读写ini文件.rar

    2019-07-09 09:12:55
    VB读写ini文件
  • VB读写INI文件的类

    2018-02-07 08:04:31
    使用VB读写INI文件,或其他文件其实都可以,非常方便。
  • VB读写INI文件

    2013-06-17 11:42:45
    使用API读写ini文件代码例子,简单好用。根据自己的需要更改即可
  • VB实际读写INI文件

    2021-01-31 22:45:00
    Private Function STRYMINI(txtym1 As String, txtym2 As String, txtym3 As String, ONOFF As Boolean) As String Dim ULR As String ULR = App.Path & “\1.ini” 'INI文件路径 Dim txtBuff As String If ONOFF =...

    在窗体上画两个按钮(Command1、Command2),一个输入框(Text1),代码如下:
    Option Explicit
    Private Declare Function GetPrivateProfileString Lib “kernel32” Alias “GetPrivateProfileStringA” (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString 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 lpFileName As String) As Long

    '注:写入与读取的[主项名]和[子项名]一定要相同!
    Private Function STRYMINI(txtym1 As String, txtym2 As String, txtym3 As String, ONOFF As Boolean) As String
    Dim ULR As String
    ULR = App.Path & “\1.ini” 'INI文件路径
    Dim txtBuff As String
    If ONOFF = True Then '读取
    '定义读取字符串的长度,“Space " 取 实 际 字 符 去 掉 字 符 后 面 多 余 的 空 格 。 t x t B u f f = S p a c e "取实际字符去掉字符后面多余的空格。 txtBuff = Space "txtBuff=Space(1000)
    '读取INI文件(主项名,子项名,空,读取子项名值,读取字符串长度,路径)
    Call GetPrivateProfileString(txtym1, txtym2, “”, txtBuff, Len(txtBuff), ULR)
    '显示实际字符串。取"txtBuff"左边的字符串(取得的字符串,字符串总长度(去掉字符串右边多余的空格字符(取得的字符串))得出字符串实际长度多一个,因此减1)
    txtBuff = Left ( t x t B u f f , L e n ( R T r i m (txtBuff, Len(RTrim (txtBuff,Len(RTrim(txtBuff)) - 1)
    '把读取到的字符串传递到"STRYMINI"函数
    STRYMINI = txtBuff
    Else
    '把字符串写入INI文件(主项名,子项名,值,保存INI文件的路径)
    Call WritePrivateProfileString(txtym1, txtym2, txtym3, ULR)
    End If
    End Function

    '写入数据:
    Private Sub Command1_Click()
    Call STRYMINI(“主项名”, “子项名”, Text1.Text, False)
    End Sub

    '读取数据
    Private Sub Command2_Click()
    Dim Txt As String
    Txt = STRYMINI(“主项名”, “子项名”, “”, True)
    If Txt <> “” Then Text1.Text = Txt
    End Sub

    展开全文
  • vb读写INI模块

    2013-08-22 14:22:10
    VB读取INI类文件的模块,在窗体中指定文件目录
  • ini文件读、写、修改等都放在doc文档里,简单明了,分类很细
  • VB读写ini文件的模块

    2012-03-19 15:43:59
    在进行程序开发时,经常要用到系统的参数配置,利用VB语言对INI文件进行读写,是我们经常要做的事。
  • VB 读写ini文件

    2014-03-03 15:29:12
     Call WriteToIni(App.Path & "\Options.ini", "Test", "Name" & Counter, "Value" & Counter) Next Counter 运行后Options.ini内容如下: [Test] Name1=Value1 Name2=Value2 Name3=Value3 ...

      首先,声明两个API函数WritePrivateProfileString和GetPrivateProfileString,一下是代码:

    Private Declare Function WritePrivateProfileString& Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lpFileName As String)


    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 Long, ByVal lpFileName As String) As Long


    Private Sub WriteToIni(ByVal Filename As String, ByVal Section As String, ByVal Key As String, ByVal Value As String)
      Dim buff As String * 128
      buff = Value + Chr(0)
      WritePrivateProfileString Section, Key, buff, Filename
    End Sub
    Private Function ReadFromIni(ByVal Filename As String,ByVal Section As String, ByVal Key As String) As String
      Dim i As Long
      Dim buff As String * 128
      GetPrivateProfileString Section, Key, "", buff, 128, Filename
      i = InStr(buff, Chr(0))
      ReadFromIni = Trim(Left(buff, i - 1))
    End Function 
    应用举例:
    一、写INI文件 
    Dim Counter As Long
    For Counter=1 To 4
      Call WriteToIni(App.Path & "\Options.ini", "Test", "Name" & Counter, "Value" & Counter)
    Next Counter
    运行后Options.ini内容如下:
    [Test]
    Name1=Value1
    Name2=Value2
    Name3=Value3
    Name4=Value4
    二、读INI文件
    Dim Counter As Long
    Dim Value(3) As String
    For Counter=1 To 4
      Value(Counter-1)=ReadFromIni(App.Path & "\Options.ini", "Test", "Name" & Counter)
    Next Counter 

    展开全文
  • VB 读写 ini 示例

    2011-07-24 21:17:11
    vb 对配置文件的读写,如保存设置等,利用到了API的相关函数
  • VB读写配置文件(ini

    千次阅读 2019-07-31 14:45:03
    .ini 文件是Initialization File的缩写,即初始化文件,是windows的系统配置文件所采用的存储格式,统管windows的各项配置,一般用户就用windows提供的各项图形化管理界面就可实现相同的配置了。但在某些情况,还是...
  • VB读写ini.doc

    2012-02-27 13:52:59
    vb中读取配置文件ini文件中的数据,或者写入数据
  • 完美的VB读写INI文件模块,包含清晰注释,修改扩展名后可以直接使用。
  • VB读写ini文件 将当前时间写入ini文件中 从ini文件中读取刚才存储的时间
  • VB.NET]读写INI文件

    2014-01-18 18:00:28
    VB.NET]读写INI文件。在本实例中,我们将应用VB.NET制作一个能够实现读写INI文件的应用程序
  • VB 读写ini的代码

    2021-09-08 11:57:01
    Attribute VB_Name = "Module1" Option Explicit Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As...
  • VB.NET读写ini配置文件.zip
  • VB6.0读写INI文件

    热门讨论 2011-03-03 12:03:55
    VB6.0读写INI文件 VB6.0读写INI文件 VB6.0读写INI文件
  • VB读写Ini文件的模块

    2009-02-15 20:53:46
    轻松读写INI文件'ini文件在有回车换行符会出错,经过测试,汉字要小于86字节,英言文要小于143字节才能返回列表框。(这是我以前的code,是记录列表框内容的)

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 1,883
精华内容 753
关键字:

vb读写ini