<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using a class to retrieve info from a CSV file. in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/using-a-class-to-retrieve-info-from-a-csv-file/m-p/1034617#M54230</link>
    <description>from the msdn

The Input # statement syntax has these parts:

      Part Description
      filenumber Required. Any valid file number.
      varlist Required. Comma-delimited list of variables that are assigned
values read from the file - can't be an array or object variable. However,
variables that describe an element of an array or user-defined type may be
used.

your var list is a list of object properties
maybe try
Dim sName as string
Dim sColor as string
Dim sLineType as str

 Input #FileNo, sName, sColor, sLineType

La.Name = sname
La.Color = scolor
La.LineType = slinetype
etc

???

"Dave F." &lt;DF&gt; wrote in message news:40a9dd51_3@newsprd01...
&amp;gt; Hi
&amp;gt; &amp;gt; &amp;gt;&amp;gt;    Input #FileNo, La.Name, La.Color, La.LineType
&amp;gt;     LayerInfoList.Add La, La.Name
&amp;gt;     Set La = Nothing
&amp;gt;  Loop    ' eof
&amp;gt;&lt;/DF&gt;</description>
    <pubDate>Tue, 18 May 2004 12:02:24 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2004-05-18T12:02:24Z</dc:date>
    <item>
      <title>Using a class to retrieve info from a CSV file.</title>
      <link>https://forums.autodesk.com/t5/vba-forum/using-a-class-to-retrieve-info-from-a-csv-file/m-p/1034616#M54229</link>
      <description>Hi

Following on from the great help I had from Bobby C. Jones, I'm getting this
problem:

The &amp;gt;&amp;gt; line is highlighting La.Name &amp;amp; giving the error:

Variable required - can't assign to this expression.

I've tested La.Name by putting a value into it &amp;amp; I've retrieved it
successfully, so the Class appears to be working OK.

I've looked in the help &amp;amp; this might be the problem, but I don't know how
to solve it:

"You used a function call or an expression as an argument to Input #, Let,
Get, or Put. For example, you may have used an argument that appears to be a
valid reference to an array variable, but instead is a call to a function of
the same name".

I've checked for functions called La - there aren't any.

Any ideas?

TIA
Dave F.

Sub UserForm_Initialize()
  Dim FileNo As Integer
  Dim La As LayerAttr
  Dim LayerInfoList As Collection

  Set LayerInfoList = New Collection
  FileNo = FreeFile

  Open "c:\dwgs\fx15\fxlayersCSV.txt" For Input As FileNo

  Do While Not EOF(FileNo)
    Set La = New LayerAttr
&amp;gt;&amp;gt;    Input #FileNo, La.Name, La.Color, La.LineType
    LayerInfoList.Add La, La.Name
    Set La = Nothing
 Loop    ' eof

  Close FileNo
End Sub

------------------------
This is the Class module named LayerAttr
------------------------
Option Explicit

Private m_Name As String
Private m_Color As String
Private m_LineType As String

Public Property Get Name() As String
  Name = m_Name
End Property

Public Property Let Name(newName As String)
  m_Name = newName
End Property

Public Property Get Color() As String
  Color = m_Color
End Property

Public Property Let Color(newColor As String)
  m_Color = newColor
End Property

Public Property Get LineType() As String
  LineType = m_LineType
End Property

Public Property Let LineType(newLineType As String)
  m_LineType = newLineType
End Property</description>
      <pubDate>Tue, 18 May 2004 09:54:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/using-a-class-to-retrieve-info-from-a-csv-file/m-p/1034616#M54229</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-05-18T09:54:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using a class to retrieve info from a CSV file.</title>
      <link>https://forums.autodesk.com/t5/vba-forum/using-a-class-to-retrieve-info-from-a-csv-file/m-p/1034617#M54230</link>
      <description>from the msdn

The Input # statement syntax has these parts:

      Part Description
      filenumber Required. Any valid file number.
      varlist Required. Comma-delimited list of variables that are assigned
values read from the file - can't be an array or object variable. However,
variables that describe an element of an array or user-defined type may be
used.

your var list is a list of object properties
maybe try
Dim sName as string
Dim sColor as string
Dim sLineType as str

 Input #FileNo, sName, sColor, sLineType

La.Name = sname
La.Color = scolor
La.LineType = slinetype
etc

???

"Dave F." &lt;DF&gt; wrote in message news:40a9dd51_3@newsprd01...
&amp;gt; Hi
&amp;gt; &amp;gt; &amp;gt;&amp;gt;    Input #FileNo, La.Name, La.Color, La.LineType
&amp;gt;     LayerInfoList.Add La, La.Name
&amp;gt;     Set La = Nothing
&amp;gt;  Loop    ' eof
&amp;gt;&lt;/DF&gt;</description>
      <pubDate>Tue, 18 May 2004 12:02:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/using-a-class-to-retrieve-info-from-a-csv-file/m-p/1034617#M54230</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-05-18T12:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using a class to retrieve info from a CSV file.</title>
      <link>https://forums.autodesk.com/t5/vba-forum/using-a-class-to-retrieve-info-from-a-csv-file/m-p/1034618#M54231</link>
      <description>Mark

Thanks, that does make it work but...

I'm confused. Because user defined types (UDT) work.
And, I maybe I'm wrong here, but aren't UDT's &amp;amp; the class routine basically
the same thing?

UDT defined in declaration area of module:

Type LayerBits
  LayNme As String
  LayCol As String
  LayLtp As String
End Type

Form object:

&lt;SNIP&gt;
Dim Lay As LayerBits
Input #FileNo, Lay.LayNme, Lay.LayCol, Lay.LayLtp
&lt;SNIP&gt;

I think (hoping) there may be another solution (I can't stand defining
Variables when they're not needed &lt;G&gt;)

Cheers
Dave F.

"Mark Propst" &lt;NOTMARK-AT-ATRENG-DOT-COM&gt; wrote in message
news:40a9fab9$1_1@newsprd01...
&amp;gt; from the msdn
&amp;gt;
&amp;gt; The Input # statement syntax has these parts:
&amp;gt;
&amp;gt;       Part Description
&amp;gt;       filenumber Required. Any valid file number.
&amp;gt;       varlist Required. Comma-delimited list of variables that are
assigned
&amp;gt; values read from the file - can't be an array or object variable. However,
&amp;gt; variables that describe an element of an array or user-defined type may be
&amp;gt; used.
&amp;gt;
&amp;gt; your var list is a list of object properties
&amp;gt; maybe try
&amp;gt; Dim sName as string
&amp;gt; Dim sColor as string
&amp;gt; Dim sLineType as str
&amp;gt;
&amp;gt;  Input #FileNo, sName, sColor, sLineType
&amp;gt;
&amp;gt; La.Name = sname
&amp;gt; La.Color = scolor
&amp;gt; La.LineType = slinetype
&amp;gt; etc
&amp;gt;
&amp;gt; ???
&amp;gt;
&amp;gt; "Dave F." &lt;DF&gt; wrote in message news:40a9dd51_3@newsprd01...
&amp;gt; &amp;gt; Hi
&amp;gt; &amp;gt; &amp;gt; &amp;gt;&amp;gt;    Input #FileNo, La.Name, La.Color, La.LineType
&amp;gt; &amp;gt;     LayerInfoList.Add La, La.Name
&amp;gt; &amp;gt;     Set La = Nothing
&amp;gt; &amp;gt;  Loop    ' eof
&amp;gt; &amp;gt;
&amp;gt;
&amp;gt;&lt;/DF&gt;&lt;/NOTMARK-AT-ATRENG-DOT-COM&gt;&lt;/G&gt;&lt;/SNIP&gt;&lt;/SNIP&gt;</description>
      <pubDate>Tue, 18 May 2004 17:33:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/using-a-class-to-retrieve-info-from-a-csv-file/m-p/1034618#M54231</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-05-18T17:33:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using a class to retrieve info from a CSV file.</title>
      <link>https://forums.autodesk.com/t5/vba-forum/using-a-class-to-retrieve-info-from-a-csv-file/m-p/1034619#M54232</link>
      <description>&amp;gt; And, I maybe I'm wrong here, but aren't UDT's &amp;amp; the class routine basically
&amp;gt; the same thing?
No UDTs are your own datatypes and classes are your own objects. The INPUT
command requires variables not properties as arguments. If you use a class,
it has properties since it is an object, and you get the error message.

I'm not even sure you should be using a class because you are not defining
anything new or different to the basic AutoCAD Layer object. What you need
to do, probably, is create a scripting dictionary object that stores the
comma-delimited data and uses the Name as the key. Then you search on the
key and SPLIT the contents apart as needed.

Also you might want to look at reading your text file in as a stream
instead of one line at a time - dpending upon how many lines you are
writing. Best method is still XML but I apologize for not having time to
post a demo that fully shows you how to accomplish what you want. [I did
post a mini to get you started, tho]</description>
      <pubDate>Tue, 18 May 2004 18:21:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/using-a-class-to-retrieve-info-from-a-csv-file/m-p/1034619#M54232</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2004-05-18T18:21:17Z</dc:date>
    </item>
  </channel>
</rss>

