Opening .ini file & using contents in textbox VBA

D

DJ MC

Hi, iv been having trouble the last couple of weeks with a bit of vb,
wondering if anyone could help. I Have a window which has a textbox ok
and cancel button, in the textbox i need the value to show the contents
of a .ini file, iv already got working that whatever the user types
into the textbox and hits OK is written to the .ini file, i just need
the textbox to display whatever value is in the file. any help
appreciated :)

Matt
 
S

Steve Rindsberg

Dj Mc said:
Hi, iv been having trouble the last couple of weeks with a bit of vb,
wondering if anyone could help. I Have a window which has a textbox ok
and cancel button, in the textbox i need the value to show the contents
of a .ini file, iv already got working that whatever the user types
into the textbox and hits OK is written to the .ini file, i just need
the textbox to display whatever value is in the file. any help
appreciated :)

Try plugging this into Google:
ini read write vb

Or go directly to The Good Stuff:

http://vbnet.mvps.org/

and search on INI
 
K

Karl E. Peterson

DJ said:
Hi, iv been having trouble the last couple of weeks with a bit of vb,
wondering if anyone could help. I Have a window which has a textbox ok
and cancel button, in the textbox i need the value to show the
contents of a .ini file, iv already got working that whatever the
user types into the textbox and hits OK is written to the .ini file,
i just need the textbox to display whatever value is in the file. any
help appreciated :)

If you need to manipulate the contents of an INI file, entry by entry,
section by section, here's a drop-in ready class that couldn't make it any
easier:

http://vb.mvps.org/samples/kpIni

It sounds, however, like "all" you're doing is just spitting the content of
a textbox to a file, and the fact it's an INI file is merely coincidental?
If so, there's a far easier way:

Public Function WriteFile(ByVal FileName As String, ByVal Text As String)
As Boolean
Dim hFile As Long
On Error GoTo Hell
hFile = FreeFile
Open FileName For Output As #hFile
Print #hFile, Text
Close #hFile
Hell:
WriteFile = Not CBool(Err.Number)
End Function

Just pass the textbox content, along with the desired filename, to that
routine.

Later... Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top