精华内容
下载资源
问答
  • VB 读取INI文件

    2016-09-18 15:05:26
    R = GetPrivateProfileString("IMP", "IMP_PATH", "", sImpPath, Len(sImpPath), App.Path & "\Param.ini")  g_imp_path = Trim...读取Ini 文件时候,如果参数中有中文,读取的值后面有很多空格 如: param.ini: [IM
    R = GetPrivateProfileString("IMP", "IMP_PATH", "", sImpPath, Len(sImpPath), App.Path & "\Param.ini")

        g_imp_path = Trim(Left(sImpPath, R))


    读取Ini 文件时候,如果参数中有中文,读取的值后面有很多空格

    如:

    param.ini:

    [IMP]
    IMP_PATH=D:\ProjectManager\20160912_海关单一窗口\program\ImpAndExpForCust\in

    读取到的值:

    'imp
        R = GetPrivateProfileString("IMP", "IMP_PATH", "", sImpPath, Len(sImpPath), App.Path & "\Param.ini")
        g_imp_path = Trim(Left(sImpPath, R))


    g_imp_path =D:\ProjectManager\20160912_海关单一窗口\program\ImpAndExpForCust\in      

    后面的空格,用trim都无法去掉





    展开全文
  • vb读取ini文件 www.52yyg.com提供
  • VB读取INI文件

    热门讨论 2011-08-15 01:33:31
    VB读取INI文件,进行程序配置,演示
  • VB 读取INI文件通用类模块代码及说明,INI经常被用作配置文件,本类主要是方便用户对INI文件的各种操作,而编写的一个类模块,包括有很多函数和方法,并附有一个使用说明。
  • VB读取INI文件

    千次阅读 2008-04-07 23:49:00
    Module1.bas代码: Option Explicit ...Private strINI As String Private Declare Function WritePrivateProfileString Lib "kernel32" Alias ...Name=VB读取ini文件 Age=25 Phone=1363868746*  

                                            

    Module1.bas代码:


    Option Explicit

    Private strINI As String
    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 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 Sub CreateIni(strDrv As String, strDir As String)
    strINI = MakePath(strDrv, strDir)
    End Sub

    Public Sub WriteIniKey(strSection As String, strKey As String, strValue As String)
    WritePrivateProfileString strSection, strKey, strValue, strINI
    End Sub

    Public Function GetIniKey(strSection As String, strKey As String) As String
    Const myinifile = "/Info.ini"
    strINI = myinifile
    Dim strTmp As String
    Dim lngRet As String
    Dim i As Integer
    Dim strTmp2 As String

    strTmp = String$(1024, Chr(32))
    lngRet = GetPrivateProfileString(strSection, strKey, "", strTmp, Len(strTmp), strINI)
    strTmp = Trim(strTmp)
    strTmp2 = ""
    For i = 1 To Len(strTmp)
    If Asc(Mid(strTmp, i, 1)) <> 0 Then
    strTmp2 = strTmp2 + Mid(strTmp, i, 1)
    End If
    Next i
    strTmp = strTmp2

    GetIniKey = strTmp
    End Function

    Public Property Let iniFileName(ByVal New_IniPath As String)
    strINI = New_IniPath
    End Property

    Public Property Get iniFileName() As String
    iniFileName = strINI
    End Property

    Public Function DelIniKey(ByVal SectionName As String, ByVal KeyWord As String)
    Dim RetVal As Integer
    RetVal = WritePrivateProfileString(SectionName, KeyWord, 0&, strINI)
    End Function

    Public Function DelIniSec(ByVal SectionName As String)
    Dim RetVal As Integer
    RetVal = WritePrivateProfileString(SectionName, 0&, "", strINI)
    End Function
     Public Function AppProFileName(iniFileName)
     iniFileName = "/Info"
    AppProFileName = App.Path & "/" & iniFileName & ".ini"
    End Function

     

     Public Function GetIniS(ByVal SectionName As String, ByVal KeyWord As String, ByVal DefString As String) As String
    Dim ResultString As String * 144, Temp As Integer
    Dim s As String, i As Integer
    Temp% = GetPrivateProfileString(SectionName, KeyWord, "", ResultString, 144, AppProFileName(iniFileName))
    '检索关键词的值
    If Temp% > 0 Then '关键词的值不为空
    s = ""
    For i = 1 To 144
    If Asc(Mid$(ResultString, i, 1)) = 0 Then
    Exit For
    Else
    s = s & Mid$(ResultString, i, 1)
    End If
    Next
    Else
    Temp% = WritePrivateProfileString(SectionName, KeyWord, DefString, AppProFileName(iniFileName))
    '将缺省值写入INI文件
    s = DefString
    End If
    GetIniS = s
    End Function

    窗体代码:

    Private Sub Command1_Click()
    Read_Info
    End Sub
    Private Sub Read_Info()

    myIni.iniFileName = App.Path & myinifile
    myIni.WriteIniKey "myInfo", "Name", Text1.Text
    End Sub

    Private Sub Command2_Click()
    Text2.Text = myIni.GetIniS("myInfo", "Name", myinifile)
    End Sub

    Ini文件:

    [myInfo]
    Name=VB读取ini文件
    Age=25
    Phone=1363868746*
     

    展开全文
  • vb读取ini文件

    千次阅读 2008-02-29 15:28:00
    '以下是读取到combobox中的代码 Imports Microsoft.VisualBasic.FileIO  Dim i As Integer  Dim f1 As String(), f2 As String()  f1 = readini("shebei.ini")  comboBox2.Items.Clear()  For i = 1 To f1....

    '以下是模块中的函数代码
        Public Function readini(ByVal filename As String) As String()

            Dim fileExists As Boolean
            fileExists = My.Computer.FileSystem.FileExists(filename)
            If fileExists Then
                Dim fields As String()
                Dim delimiter As String = ","
                Using parser As New TextFieldParser(filename)
                    parser.SetDelimiters(delimiter)
                    While Not parser.EndOfData
                        ' Read in the fields for the current line
                        fields = parser.ReadFields()
                        ' Add code here to use data in fields variable.

                    End While
                    Return fields
                End Using

            Else
                My.Computer.FileSystem.WriteAllText(filename, ",", False)
            End If


        End Function
    '------------------------------------------------------------------------
    '以下是读取到combobox中的代码
    Imports Microsoft.VisualBasic.FileIO
            Dim i As Integer
            Dim f1 As String(), f2 As String()
            f1 = readini("shebei.ini")
            comboBox2.Items.Clear()
            For i = 1 To f1.Length - 2
                comboBox2.Items.Add(f1(i))
            Next

     

    展开全文
  • 利用vb读取ini文件,并写入excel
  • 利用vb读取ini文件

    2009-06-08 17:15:32
    VB 读写 ini文件 相当使用的一个类,建议大家看以下
  • VB读取ini文件的函数

    千次阅读 2007-02-08 09:41:00
    ErrorMsg = "INI file has not been specifyed!" Exit Function End If If WritePrivateProfileString(Section, key, Value, iniFileName) = 0 Then ErrorMsg = "Failed to write to the ini file!" Exit Function ...

    Option Explicit

    Private Declare Function GetPrivateProfileInt Lib "kernel32" _
    Alias "GetPrivateProfileIntA" (ByVal lpApplicationName As String, _
    ByVal lpKeyName As String, _
    ByVal nDefault As Long, _
    ByVal lpFileName As String) As Long

    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

    Public ErrorMsg As String

    Private Sub Class_Initialize()
    ErrorMsg = vbNullString
    End Sub

    '写入----------------------------------
    Public Function WriteString(iniFileName As String, Section As String, key As String, Value As String) As Boolean
    WriteString = False
    ErrorMsg = vbNullString
    If iniFileName = "" Then
    ErrorMsg = "INI file has not been specifyed!"
    Exit Function
    End If
    If WritePrivateProfileString(Section, key, Value, iniFileName) = 0 Then
    ErrorMsg = "Failed to write to the ini file!"
    Exit Function
    End If
    WriteString = True
    End Function

    '读出字符串----------------------------
    Public Function ReadString(iniFileName As String, Section As String, key As String, Size As Long) As String
    Dim ReturnStr As String
    Dim ReturnLng As Long
    ErrorMsg = vbNullString
    ReadString = vbNullString
    If iniFileName = "" Then
    ErrorMsg = "INI file has not been specifyed!"
    Exit Function
    End If
    ReturnStr = Space(Size)
    ReturnLng = GetPrivateProfileString(Section, key, vbNullString, ReturnStr, Size, iniFileName)
    ReadString = Left(ReturnStr, ReturnLng)
    End Function

    '读出数值-----------------------------
    Public Function ReadInt(iniFileName As String, Section As String, key As String) As Long
    Dim ReturnLng As Long
    ReadInt = 0
    ErrorMsg = vbNullString
    If iniFileName = "" Then
    ErrorMsg = "INI file has not been specifyed!"
    Exit Function
    End If
    ReturnLng = GetPrivateProfileInt(Section, key, 0, iniFileName)
    If ReturnLng = 0 Then
    ReturnLng = GetPrivateProfileInt(Section, key, 1, iniFileName)
    If ReturnLng = 1 Then
    ErrorMsg = "Can not read the ini file!"
    Exit Function
    End If
    End If
    ReadInt = ReturnLng
    End Function 

    展开全文
  • vb 读取ini文件(API函数使用)

    千次阅读 2007-08-20 18:24:00
    ’叁数四 .ini文件的名称 success = WritePrivateProfileString("MyApp", "text2", Text2.Text, "c:aa.ini") success = WritePrivateProfileString("MyApp2", "text3", Text3.Text, "c:aa.ini") ...
  • vb6读取INI文件

    2010-07-13 21:58:58
    大家都知道,软件安装好后,都会有个ini配置文件,vb6读取ini文件的例子,已经写成类了,可以方便大家使用!
  • vb.net vs2008读取INI文件示例,ini文件名为 Send.ini,代码中包括了一个读ini API函数。  Ini文件说明:  [节名] []中的节名对应此API的第一参数  Name=内容 Name对应此API的第二参数  API的第三参数是没有取到...
  • VB6读取INI文件

    千次阅读 2017-12-06 10:03:15
    程式版本更新, 读取INI文件做对比, 确认版本是否最新. 可用VB6的工具下的API检视员来自动生成API调用代码. INI文件内容: [Version] TEST=2017-11-20 00:00:00 调用API. Private Declare Function ...
  • NeMoReadIniFileVB.Net程序设计:读取ini文件和读取xml文件的例子,程序首先演示了如何读取ini文件到ComboBox中,然后演示读取XmL文件到ComboBox中,VS.net内置对xml的操作可以参考: System.Xml 和 System.Xml.Xml...
  • 自从注册表诞生以来ini文件正在逐渐失去其市场占有率,然而基于ini文件的独立性,致使其还没有到达退出历史舞台的地步,很多应用程序的初始化和一些界面参数的设置仍然很愿意从ini文件读取,为了保证操作需用参数...
  • VB.NET实现读取INI文件示例,在VS2008开发
  • 用FileSystemObject对象读取INI 文件 支持 VB读INI VBS读INI ASP 读INI '作者:CSDN 许仙 'Homepage : jjweb.126.com'MSN :Coderxu#hotmail.com'QQ:19030300'转载请保持文章完整,保存以上作者信息 请...
  • 通过读取INI文件中的SQL SERVER配置信息来读取SQL SERVER数据库
  • 一个读取INI文件的模块,在书上找到的,并进行了更改。在写软件时将一些参数放到INI文件里是非常方便更改的,我经常用到,可能大家还有有人需要用到,可是一直苦于不懂得怎么去读INI文件,哈哈,现在可以用这个模块...
  • VB.Net读取ini文件的例子,和读取xml文件的例子。两种方法的比较。建议还是用Xml比较好。System.Xml
  • vb读取ini文件,“;”后为注释内容。
  • 以前发了一个读写INI文件的模块,现在再发一个读写INI文件的DLL,这样大家就可以使用其他语言来读写INI文件了。内含详细使用说明,请参阅Readme.txt文件。在写软件时将一些参数放到INI文件里是非常方便更改的,我...
  • vb.net 读取ini文件vb6中能读取,升迁到vb.net2008后读取不到ini文件 Option Strict Off Option Explicit On Module ModConString Private strIPAddress As String Private iniPath As String Function...
  • vb.net 读取ini文件

    千次阅读 2011-12-21 09:51:44
    Imports Microsoft.VisualBasic.CompilerServices Public Class CtrlIni Public Property iniFilePath As String Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivatePr
  • ReadINI VB6.0读取INI文件的例程

    热门讨论 2008-10-08 09:23:41
    以前发了一个用VB6.0编写的读写INI文件的DLL,现在公布两个使用此DLL的例程。内含详细使用说明,请参阅Readme.txt文件。DLL下载地址:http://download.csdn.net/source/669094
  • vb读取文本文件txt,ini

    2009-10-15 14:22:23
    vb读取文本文件txt,ini文件的方法,仅供菜鸟学习
  • 读取INI文件VB源代码

    2009-09-22 13:00:23
    VB中利用API函数读取INI配置文件的源代码。 希望能给需要的VB爱好者提供些许方便。
  • 读取INI文件VB

    2008-06-10 15:56:44
    可以直接读取INI文件内容,使用很方便。
  • vb ini文件读取与写入

    2014-12-18 15:51:42
    vb ini配置文件读取与写入

空空如也

空空如也

1 2 3 4 5 ... 9
收藏数 165
精华内容 66
关键字:

vb读取ini文件