<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno gio 16 lug 2020 alle ore 21:10 T Lee Davidson <<a href="mailto:t.lee.davidson@gmail.com" target="_blank">t.lee.davidson@gmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 7/16/20 1:24 PM, Gianluigi wrote:<br>
> But in the wiki it says "as Object" or "as Variant" if you change to Variant it works.<br>>...<br>
Where are you seeing the Wiki say "as Object" or "as Variant"? I haven't found that.<br>
<br></blockquote><div><br></div><div>Hi Lee,<br><br>I read it here:<br><a href="http://gambaswiki.org/wiki/lang/write" target="_blank">http://gambaswiki.org/wiki/lang/write</a><br><br>Here with Class1 this code works.<br>'-----------------------------------------<br>' Gambas module file<br><br>Private hFile As File<br>Private hObj As New Class1<br><br>Public Sub Main()<br><br>  ' Once the file has been written, you can also Try To read (Leggi) it only, commenting On Scrivi (Write)<br>  Scrivi ' Write in italian<br>  Leggi ' Read ...<br><br>End<br><br>Private Sub Scrivi()<br><br>  ' Dim hFile As File<br>  ' Dim hObj As New Class1<br><br>  hFile = Open "/tmp/TestReadWrite" For Write Create<br>  hObj.Name = "TestReadWrite"<br>  hObj.Bird = Date(Now)<br>  Write #hFile, hObj As Object ' or variant<br>  Close #hFile<br><br>End<br><br>Private Sub Leggi()<br><br>  ' Dim hFile As File<br>  ' Dim hObj As New Class1 ' The object must refer to the class otherwise it causes an error.<br><br>  hFile = Open "/tmp/TestReadWrite" For Read<br>  hObj = Read #hFile As Variant ' or object<br>  Print "The file is named "; Quote(hObj.Name); " and it is created the: "; Format(hObj.Bird, gb.LongDate)  ' Print the name and date on the console<br>  Close #hFile<br><br>End<br>'------------------------------------------------</div><div><br></div><div>Regards</div><div>Gianluigi<br></div></div></div>