Results 1 to 5 of 5
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Australia
    Posts
    1,294
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VB code - how to obtain info from ini files

    Hi ya

    I'm not familiar with VB & have currently been asked to code in VB (because I know VBA).
    In a .ini file there are fields with data.
    I want to obtain specific information from the .ini file & display in form.
    I have that code in VBA - I copied & pasted in VB & of course it doesnt work(I believe the syntax is slightly different Y/N?)
    (I've installed VB6 however I dont have access to help files to assist me.)
    Does anyone have existing VB code to perform the above.

    Also post new lounge, there were links/web addresses to some VB sites with sample code - does anyone have these details.
    Thanks in advance - Diana

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: VB code - how to obtain info from ini files

    You could try the following links for some relevant code
    http://www.vb-world.net/demos/ini/
    http://searchvb.techtarget.com/
    http://www.cgvb.com/
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB code - how to obtain info from ini files

    Welcome back to the board Andrew. You've been missed.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  4. #4
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB code - how to obtain info from ini files

    I'm within a day or two of providing a solution for you.

    Over the past few days I've begun pasting some low-level code (subject line "Code:") in this forum, all leading up to lovely generic routines to read/write INI files from user applications (Word, Excel, Access, PPT etc) *and* sweet GUI forms development to manage the same. When this burst of activity is complete, you'll not only have INI files, you'll not only have GUI forms, you'll have an envelope processor that makes Woody wonder why he bothered with WOPR in the first place!

    <pre>


    This is already available:

    Code for string manipulation February 16th 2001
    BoolAlphaOnly
    StrAlphaOnly
    strOnly




    This is being posted as we squeak:

    Code for INI files February 17th 2001
    StrGP
    StrBreakFilestring
    BoolAlphaOnly
    StrPPS
    StrPP
    StrBreakFileString
    strPPS




    This is in the pipeline:

    Code for creating a form
    FrmHeader
    UserForm_Initialize
    cmdRefresh_Click
    StrGp
    cmdSave_Click
    strPP
    cmdOK_Click
    cmdSave_Click
    cmdCancel_Click
    </pre>


  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: VB code - how to obtain info from ini files

    Here's some lines I use in an Outlook VBA module. Doesn't rely on Word's special methods, so should port over to VB fairly well.

    <pre>'Declarations for accessing .ini files
    Declare Function GetPrivateProfileString Lib "kernel32" _
    Alias "GetPrivateProfileStringA" (ByVal lpSectionName As String, _
    ByVal lpKeyName As Any, ByVal lpDefault As String, _
    ByVal lpReturnedString As String, ByVal nSize As Long, _
    ByVal lpFileName As String) As Long

    Declare Function WritePrivateProfileString Lib "kernel32" _
    Alias "WritePrivateProfileStringA" (ByVal lpSectionName As String, _
    ByVal lpKeyName As Any, ByVal lpString As String, _
    ByVal lpFileName As String) As Long

    ...

    lAdminAddrLen = GetPrivateProfileString("MacroSettings", "AdminEmail", _
    strDefaultValue, strAdminEmail, 255, "c:my documentsmyOL2K.ini")

    ...

    If WritePrivateProfileString("MacroSettings", "AdminEmail", _
    Me.txtAdminEmail.Text, "c:my documentsmyOL2K.ini") = 0 Then
    MsgBox "Error saving admin info for next time..."
    End If
    </pre>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •