?
Solved

Why use xml over ini files

Posted on 2003-03-21
3
Medium Priority
?
535 Views
Last Modified: 2010-05-01
I have just began a new project and have decided to use XML or XLS files to store project data instead of INI files.Should I stay with *.ini or should  I change?? Which type should I use?? what is the difference between XML and XLS
when I read and write to an Ini file  I use the following code.what do I use for XML or XLS?


Option Explicit

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
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 Function WriteIniInfo(FileName As String, AppName As String, KeyName As String, StringName As String)
Dim x As Boolean
    x = WritePrivateProfileString(AppName, KeyName, StringName, FileName)
End Function

Public Function GetIniInfo(FileName As String, AppName As String, KeyName As String)
Dim A As String
Dim i As String
 A$ = Space$(255)
     i = GetPrivateProfileString(AppName, KeyName, "", A$, 300, FileName)
      GetIniInfo = Left$(A$, i)
End Function
0
Comment
Question by:visualbasic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 2000 total points
ID: 8179996
Hi visualbasic,

XML can be very useful because you can declare an ADODB.Recordset object and load your configuration directly into it (assuming the XML is appropriately formatted). This is easily achieved by creating a disconnected recordset and using the .Save method of it. Then you can simply reload the recordset and make any changes to the configuration, save it again and it is updated.

XLS is the file format supported by Microsoft Excel, I personally wouldn't even consider this for this task.

Generally the debate in these situations is related to using the registry over .ini files, configuration files of any form are often considered outdated but they do have a use. It is often easier to modify the configuration in this way than to make registry changes (especially if you are not an administrator on your machine).

XML is a good way of preserving such information in a simple way and is a good replacement for api functions and the .ini file mechanism.

Tim Cottee MCSD, MCDBA, CPIM
http://www.timcottee.tk 

Brainbench MVP for Visual Basic
http://www.brainbench.com

Experts-Exchange Advisory Board Member
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 8183009
>>XLS is the file format supported by Microsoft Excel, I personally wouldn't even consider this for this task.<<

I suspect the questioner mistyped and meant to write XSL.

Anthony
0
 

Expert Comment

by:CleanupPing
ID: 8531892
Hi visualbasic,
This old question (QID 20558480) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question