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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Function - Need Help 1

Status
Not open for further replies.

AGNEW2PRG

Technical User
Aug 5, 2003
98
AE
Hi,

The following script works if I insert a inputbox as srchstring within the function. How do I assign the srchstring as a variable that can call the function and get the value in the config.inf file? I hope i am explaining this properly.

many thanks

the config.inf file

IPADDRESS=10.0.0.1

<------------------------------------------------------->
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
Set oFile = FSO.OpenTextFile("c:\mfpconfig\config.inf")

srchString=search(IPADDRESS)

'<---------------- Search Function---------------------------->

Function search()

Do Until oFile.AtEndOfStream

strLine = oFile.ReadLine

If InStr(strLine, srchString) Then

strTmp = Split((strLine), "=")

End If

Loop
MsgBox strTmp(1)

End Function
 
Set FSO = CreateObject("Scripting.FileSystemObject")
MsgBox search("IPADDRESS")

Function search(srchString)
Set oFile = FSO.OpenTextFile("c:\mfpconfig\config.inf")
Do Until oFile.AtEndOfStream
strLine = oFile.ReadLine
If InStr(strLine, srchString) Then
search = Split(strLine, "=")(1)
Exit Do
End If
Loop
oFile.Close
End Function

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Super,

Thats all I needed, thanks for your help.



" New To Programming - Learning Fast :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top