• 0

[VB] Reading/Writing INI?


Question

Hi everybody, does any one know a class to read and write to a Ini file in VB??? I have been serching but the ones I found @Google, aren't quite good..

Thanks in advance :cool:

Link to comment
Share on other sites

10 answers to this question

Recommended Posts

  • 0
Hi everybody, does any one know a class to read and write to a Ini file in VB??? I have been serching but the ones I found @Google, aren't quite good..

Thanks in advance :cool:

.NET or VB6??

StreamReader and StreamWriter class. :)

You could also use XML.

Link to comment
Share on other sites

  • 0
You could also use XML.

Know of any good resources or tutorials where I could get some good on how to implement that. I want to add some system of storing the user's preferences for an app i'm coding. Currently, i'm thinking of using the registry but I might consider XML. :D

Link to comment
Share on other sites

  • 0

I did a project last year where I had to write and read to/from ini files in VB6 using a class. This year I had a new project in VB.NET. I had to convert my own classes to .NET to be able to read/write from/to ini files. If you need them I could upload them for you.

EDIT: I just looked on my PC and I can't find those projects here. I must've left them on the company's laptop. If you realy need them I could contact them and ask for my files.

Link to comment
Share on other sites

  • 0
Know of any good resources or tutorials where I could get some good on how to implement that. I want to add some system of storing the user's preferences for an app i'm coding. Currently, i'm thinking of using the registry but I might consider XML. :D

I 2nd that. Is there any good tuts out there?

Link to comment
Share on other sites

  • 0

using VB.NET & DOM...

thefile.xml

<?xml version="1.0" encoding="utf-8" ?>
<Base>
 ?<Item name="" />
</Base>

Saving... Information:

Dim myXml as System.Xml.XmlDocument = new System.Xml.XmlDocument()
myXml.Load("thefile.xml")
myXml.DocumentElement.ChileNodes[0].Attribute["name"].Value = "Me!"
myXml.Save("thefile.xml")

Loading...

Dim myXml as System.Xml.XmlDocument = new System.Xml.XmlDocument()
Dim sName as String = ""
myXml.Load("thefile.xml")
sName = myXml.DocumentElement.ChileNodes[0].Attribute["name"].Value

Result:

<?xml version="1.0" encoding="utf-8" ?>
<Base>
 ?<Item name="Me!" />
</Base>

Well thats how i do it... i use C# usualy...

hope it helps... and sets u on your way.

Link to comment
Share on other sites

  • 0
I did a project last year where I had to write and read to/from ini files in VB6 using a class. This year I had a new project in VB.NET. I had to convert my own classes to .NET to be able to read/write from/to ini files. If you need them I could upload them for you.

EDIT: I just looked on my PC and I can't find those projects here. I must've left them on the company's laptop. If you realy need them I could contact them and ask for my files.

Thanks for the offer but I think that with Ph8l's sample code I should be fine now. I can experiment with it and try to learn as I go along. Just a question: Where in Belgium do you live? As you might have noticed I live in Brussels and it would be good to know of other Neowinians living here too :D

@Ph8l: Thanks for the code sample

Link to comment
Share on other sites

  • 0

Wow, no I must've missed that! I live in Gistel near Oostende.

Maybe it's better to start using XML anyway, I used ini in .NET just because I was used to work with those files from VB6.

It looks like it's a lot easier to use XML in .NET now.

Good luck!

Link to comment
Share on other sites

  • 0
Wow, no I must've missed that! I live in Gistel near Oostende.

Maybe it's better to start using XML anyway, I used ini in .NET just because I was used to work with those files from VB6.

It looks like it's a lot easier to use XML in .NET now.

Good luck!

I really like it in Oostende - Been there quite a few times. Only problem is it get's really busy there in summer :wacko:

Going ontopic, as you mentioned I think maybe XML may be the way forward. I'm still a beginner at VB.NET so I think it would be more worthwhile for me to learn how to use XML instead of INI, which is getting somewhat dated.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.