Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working with strings?

Status
Not open for further replies.

kurgan383

IS-IT--Management
Jan 7, 2003
17
US
Hi all... I want to read an .ini file and replace some data in it. I can read the file with streamreader, but how do I replace a line of data?
 
Hi,

I tend to do something like this...

dim strFilename as string
dim strRunning as string
dim strTemp as string

strFilename="c:\setup.ini" 'or whatever the ini file is

FileOpen(1, strFilename, OpenMode.Input)

while not eof(1)
input(1, strTemp)
if strTemp="Startup=True" then 'or whatever you want to change
strRunning=strRunning + "Startup=False" + vbnewline
Else
strRunning=strRunning + strTemp + vbnewline
End if
wend

fileclose(1)
fileopen(1, strFilename, OpenMode.Output)
print(1, strRunning)
fileclose(1)

If you want to check just for the first part of the 'variable' you can use:

if left(strTemp, 7)="StartUp"

As the test instead.

Hope that helps you!!!

Bob.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top