Wrox Programmer Forums
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 14th, 2004, 10:17 AM
Authorized User
 
Join Date: Jun 2003
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Default Read data from ini file

Is there a way to read in data from an ini file for a windows application. I was able to do this in VB6.

Oops forgot to say I need this for VB.NET.
 
Old January 14th, 2004, 10:21 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think I missed something. What are you programming in VBA, VB.NET ???

Larry Asher
 
Old January 14th, 2004, 10:23 AM
Authorized User
 
Join Date: Jun 2003
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes its VB.NET Larry. Sorry I forgot to post that on original message, which i've edited now.

Thanks
 
Old January 14th, 2004, 10:55 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

This post probably belongs in the one of the .NET forums...

.INI files are not used in the .NET world; instead, they are replaced by .config files, which are XML documents which (among other things) contain key/value pairs. The System.Configuration namespace has classes which allow you to read (but not easily write) them.

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
 
Old January 15th, 2004, 09:16 AM
Authorized User
 
Join Date: Jun 2003
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Jeff

Works well
 
Old April 2nd, 2015, 05:14 AM
Registered User
 
Join Date: Apr 2015
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default RE: Read data from ini file

Even though XML based .config files are a preferred way, sometimes we don't have a choice. In that case you can use this VB.NET library that can read INI file's content and if needed update it as well.
It can also provide you a way to retrieve and use INI data in strongly typed manner, for example:
Code:
Dim ini As New IniFile()
ini.Load("Sample.ini")

Dim sampleInt As Integer
ini.Sections(0).Keys("Sample Number").TryParseValue(sampleInt)

Dim sampleDate As DateTime
ini.Sections(0).Keys("Sample Date").TryParseValue(sampleDate)





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to read data from an excel file diegoblin Beginning VB 6 6 August 31st, 2009 11:04 PM
Read Data from Excel File kiwibey ASP.NET 2.0 Professional 1 December 5th, 2006 11:27 AM
How to read and update .INI files using Pure C ?? Poonam C++ Programming 1 March 24th, 2005 01:22 AM
How to Read from INI file alen Pro VB 6 2 September 3rd, 2004 06:34 AM
Read data from a text file (*.txt) adriant42 Excel VBA 2 June 4th, 2004 06:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.