Problem: I am attempting to replace a key-value pair within a text file. The Key is staying the same while the value is changing. I don't want to modify any other lines except the single line that starts with the keyname.
What I have currently:
Sub REPLACESESSIONID()
Dim CONTENT, SESSIONID, WORKINGDIR As String
SESSIONID = "urn:uuid:A750ADE2355E6EAA2315397874423"
SESSION = FreeFile()
' ESTABLISH WORKING DIRECTORY
WORKINGDIR = Environ("AppData") & "\PROJECT"
' READ SESSION.TXT AND STORE AS VARIABLE
Open WORKINGDIR & "\SESSION.txt" For Input As #SESSION ' Open file
CONTENT = Input(LOF(SESSION), SESSION)
Close #SESSION
' REPLACE SESSIONID* WITH NEW SESSIONID
CONTENT = Replace(CONTENT, "SESSIONID*", "SESSIONID;" & SESSIONID)
' WRITE CHANGES TO SESSION.TXT
Open WORKINGDIR & "\SESSION.txt" For Output As #SESSION
Print #SESSION, CONTENT
Close #SESSION
End Sub
I am aware that Replace does not allow wildcards, but am unsure how proceed.
Contents of SESSION.txt:
SESSIONID;urn:uuid:A7AGBDE25436EAA231532239423
ROLENAME;Local_Unix_Admin