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.

Signature
Regards,
Tom Ogilvy
> What is the simplest way to read and write maybe 3 values to a text
> file?
[quoted text clipped - 4 lines]
>
> Matts
Tom Ogilvy - 03 Feb 2006 18:56 GMT
Small correction. While that will work for what I presented, you should
actually use WRITE rather than PRINT. Here is a revision.
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
Write #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

Signature
Regards,
Tom Ogilvy
> Public V1
> Public V2
[quoted text clipped - 33 lines]
> http://www.excelforum.com/member.php?action=getinfo&userid=31134
> > View this thread: http://www.excelforum.com/showthread.php?threadid=508222
mattsvai - 03 Feb 2006 19:17 GMT
You're very helpful Tom :)
I will give it a shot...
Matt
clayton - 30 Mar 2006 01:55 GMT
Awesome bit of code! Will come in very handy. Thank you very much! :