Thread: Read/Write
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Read/Write

Public V1
Public V2
Public V3

Sub WriteValues()
Dim f As Long
V1 = Int(Rnd() * 100 + 1)
V2 = Int(Rnd() * 100 + 1)
V3 = Int(Rnd() * 100 + 1)
f = FreeFile
Open "C:\MyVar.ini" For Output As #f
Print #f, V1, V2, V3
Close #f
End Sub

Sub ReadValues()
Dim f As Long
f = FreeFile
Open "C:\MyVar.Ini" For Input As #f
Input #f, V1, V2, V3
Close #f
MsgBox V1 & " - " & V2 & " - " & V3
End Sub

You can remove the V1 = type statements - they are just for texting.

--
Regards,
Tom Ogilvy


"mattsvai" wrote in
message ...

What is the simplest way to read and write maybe 3 values to a text
file?
I want to use this as a global variables container so that all xls
files can be in sync.

Thanks,

Matts


--
mattsvai
------------------------------------------------------------------------
mattsvai's Profile:

http://www.excelforum.com/member.php...o&userid=31134
View this thread: http://www.excelforum.com/showthread...hreadid=508222