Discussion:
Read ini File into Textbox VB .net 2005
(too old to reply)
DJ MC
2009-01-19 15:46:34 UTC
Permalink
Hi,
ive been trolling google for a while now and cannot find my answer so
im hoping someone can help me. Ive had previous experience with VBA in
excel and made a couple of programs, im now given the task of
understanding visual studio 2005 and creating a program with this
software. i feel my knowledge of VB .net is next to none as whatever i
type just isnt working :(

Anyways...i have a form with 13 textboxes already populated, what i
need to do is whenever the form is loaded it opens a .ini file and
reads the lines and populates each textbox accordingly, this is
my .ini file:
[Textbox Values]
Frm01=Textbox1value
Frm02=Textbox2value
Frm03=Textbox3value
Frm04=Textbox4value
Frm05=Textbox5value
Frm06=Textbox6value
Frm07=Textbox7value
Frm08=Textbox8value
Frm09=Textbox9value
Frm10=Textbox10value
Frm11=Textbox11value
Frm12=Textbox12value
Frm14=Textbox14value

I got this piece of code from a microsoft site to start me off, im not
sure if this is the best way to go but this should open the ini and
read the lines in the file.

Dim objStreamReader As StreamReader
Dim StrLine As String

Do While Not StrLine Is Nothing
objStreamReader = New StreamReader("C:\SubContratorXML
\Textboxes.ini")
StrLine = objStreamReader.ReadLine
Loop

From this point im stuck on how i would be able to read the string
after the "=" and then populate it into the correct textbox. any help
would be much appreciated.

Thanks
harid
2009-04-03 12:03:01 UTC
Permalink
The code you've mentioned reads the file line-by-line. Assuming that the data
in the .ini file is always in order and each entry in the file is on a new
line, you can save the contents of the file into an array. Use this array to
populate the textboxes.
Post by DJ MC
Hi,
ive been trolling google for a while now and cannot find my answer so
im hoping someone can help me. Ive had previous experience with VBA in
excel and made a couple of programs, im now given the task of
understanding visual studio 2005 and creating a program with this
software. i feel my knowledge of VB .net is next to none as whatever i
type just isnt working :(
Anyways...i have a form with 13 textboxes already populated, what i
need to do is whenever the form is loaded it opens a .ini file and
reads the lines and populates each textbox accordingly, this is
[Textbox Values]
Frm01=Textbox1value
Frm02=Textbox2value
Frm03=Textbox3value
Frm04=Textbox4value
Frm05=Textbox5value
Frm06=Textbox6value
Frm07=Textbox7value
Frm08=Textbox8value
Frm09=Textbox9value
Frm10=Textbox10value
Frm11=Textbox11value
Frm12=Textbox12value
Frm14=Textbox14value
I got this piece of code from a microsoft site to start me off, im not
sure if this is the best way to go but this should open the ini and
read the lines in the file.
Dim objStreamReader As StreamReader
Dim StrLine As String
Do While Not StrLine Is Nothing
objStreamReader = New StreamReader("C:\SubContratorXML
\Textboxes.ini")
StrLine = objStreamReader.ReadLine
Loop
From this point im stuck on how i would be able to read the string
after the "=" and then populate it into the correct textbox. any help
would be much appreciated.
Thanks
Loading...