Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Read Value Pairs from a Text File VB.NET

Posted on 2015-02-19
2
Medium Priority
?
288 Views
Last Modified: 2015-02-21
I'm looking for the best way to read values from a text file into a vb.net winforms application.

I'm hoping to take regular messages like "Couldn't connect to the database" or "We were not able to complete the task" and put it in a text file like this:

1, "Couldn't connect to the database"
2, "We were not able to complete the task"

So that someone without a lot of experience programming could change the messages if they wanted. (for example, they could change the to a different language.

It would be great as well if this could be done with comments like this:

\\Error Messages
1, "Couldn't connect to the database."
2, "We were not able to complete the task."

\\System Update
3, "We updated the information successfully."
4, "Please enter your username"

My goal is to be able to refer to the number to get to the message.  I thought perhaps I could do it using Dictionary, it seems like the values have to be hard coded...  I could read List (Of T), but that would mean that the items have to be in order and I'd have to loop through the entire list to get what I want... doesn't seem too efficient.

I'd rather not use a database for this - but if I have to, I guess I will.
Any suggestions on the best course of action would be helpful!

Thanks for your time!!!
0
Comment
Question by:slightlyoff
[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
2 Comments
 
LVL 36

Accepted Solution

by:
Miguel Oz earned 2000 total points
ID: 40620909
You could use an xml to store the values:
<?xml version="1.0" encoding="utf-8"?>
<errors>
<error id='int_goes_here' value='string_goes_here'/>
</errors>

Open in new window


and read those values to a Dictionary<int, string> instance as shown here. Notice that posted link use items/item that you should map to your current xml construct errors/error.
0
 
LVL 1

Author Comment

by:slightlyoff
ID: 40623419
Thank you very much!  That seems much better than what I was thinking :)

Thank you for your time!
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

688 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