Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 -- Regards, Tom Ogilvy "Tom Ogilvy" wrote in message ... 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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() You're very helpful Tom :) I will give it a shot... Matt -- mattsva ----------------------------------------------------------------------- mattsvai's Profile: http://www.excelforum.com/member.php...fo&userid=3113 View this thread: http://www.excelforum.com/showthread.php?threadid=50822 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Awesome bit of code! Will come in very handy. Thank you very much! : -- clayto ----------------------------------------------------------------------- clayton's Profile: http://www.excelforum.com/member.php...nfo&userid=456 View this thread: http://www.excelforum.com/showthread.php?threadid=50822 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
read only and write only | New Users to Excel | |||
I have a read only xl file, I need it to be read and write | Excel Discussion (Misc queries) | |||
How can a file be converted from Read-Only to Read/Write | Excel Discussion (Misc queries) | |||
Who has read/write | Excel Programming | |||
write to/read from add-ins | Excel Programming |