Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 04-11-2009
Member
 
Join Date: Nov 2009
Posts: 37
Reading from INI file to several textbox in VB.NET

Hello everyone, I have a small question. I built a form where there are several textbox that contain the values read from a file .ini for example:

Server Name = Daniel -> textBox1.Text = Daniel
Admin Name = Charles -> Charles TextBox2.Text =
.. and so on ..

I should also be able to save the file as a function of changes in my form. How could I begin with the code? What is feasible?
Reply With Quote
  #2  
Old 04-11-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: Reading from INI file to several textbox in VB.NET

Certainly, the basic idea is to open the file for reading, read it line by line and launch the update of textbox with instructions such as

TextboxN.text = <String read by file>

I suppose more than that VB.NET has evolved to read an INI file without having to scroll line by line and then parse the line read to get the search string
Reply With Quote
  #3  
Old 04-11-2009
Member
 
Join Date: Nov 2009
Posts: 37
Re: Reading from INI file to several textbox in VB.NET

Very well, thank you!

You have suggestions? Know that I am a novice in the field

I read by StreamReader, I can make him read a full text file and fill a textbox but to discriminate the words still make him not stand.
Reply With Quote
  #4  
Old 04-11-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: Reading from INI file to several textbox in VB.NET

Hello,

I mean an external INI file or want to make a resource or config etc. ..?

I guess the first, try to post the structure of this file, because I believe that we should do a little hand to read.
Reply With Quote
  #5  
Old 04-11-2009
Member
 
Join Date: Nov 2009
Posts: 37
Re: Reading from INI file to several textbox in VB.NET

What place is only a portion of "INI" I do not need all its parametric content but only a few ...

ServerBehindNAT=false
DoLANBroadcast=False
bIgnoreUTANBans=True
ServerName=++ Enjoy II ++ The [BuG] Server
AdminName=ARIX
UsePrecaching=True

etc. ..

have ideas? Thanks for your interest ..
Reply With Quote
  #6  
Old 04-11-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: Reading from INI file to several textbox in VB.NET

If the lines are always "equal" in the sense that they are always <key> = <value>

That's enough for the laws line by line and split the equal sign.

For example

Code:
Dim strLine As String() = File.ReadAllLines("path")
Dim ValueFileINI As String 
Dim key As String ="AdminName"
                For Each strLine As String In strLine
                    If strLine.IndexOf("=") > -1 Then
                        If key = strLine.Split("=")(0) Then
                           ValueFileINI = strLine.Split("=")(1)
                         End If
                     End If
                Next

I don't have anything to test, but should be working.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Reading from INI file to several textbox in VB.NET"
Thread Thread Starter Forum Replies Last Post
Excel/VBA: Copying text from UserForm Textbox to a Worksheet Textbox Neil Ives Software Development 2 20-08-2010 01:23 AM
Reading text file in VC++ display it in textbox molocas Software Development 1 26-07-2010 10:34 AM
Reading XML file with ASP Dharamsi Software Development 4 10-03-2010 10:47 PM
Reading file bit by bit John Wilson Software Development 4 14-12-2009 01:49 PM
Java reading from a file xqc72 Software Development 1 20-11-2009 08:20 AM


All times are GMT +5.5. The time now is 08:25 AM.