Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Property Get with argument

Dear friends,

I am trying to write a class that will parse XML data. I have a property
called TagName. Since there are many tags I wanted to index them. Even
though in the syntax of Property Get statement an argument can be used when
I attempt to use the following code I get an "Compile error: Can't assign to
read-only property." error.

Public Property Let TagName(ByVal intI As Integer)
TagName(intI) = ParsedData(intI)
End Property
Any suggestions are appreciated
Ömer Ayzan



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default Property Get with argument

Hi Ömer,

The TagName property is a single value, not an array. The way you have
it defined (which I think is what you want) is that the desired array index
is passed in and the single value from that array is returned. In that case
it should work if modified as follows:

Public Property Let TagName(ByVal intI As Integer)
TagName = ParsedData(intI)
End Property

This assumes that ParsedData is a valid array and that intI is a valid index
into that array.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Ömer Ayzan" wrote in message
...
Dear friends,

I am trying to write a class that will parse XML data. I have a property
called TagName. Since there are many tags I wanted to index them. Even
though in the syntax of Property Get statement an argument can be used

when
I attempt to use the following code I get an "Compile error: Can't assign

to
read-only property." error.

Public Property Let TagName(ByVal intI As Integer)
TagName(intI) = ParsedData(intI)
End Property
Any suggestions are appreciated
Ömer Ayzan





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Property Get with argument

Rob in my earlier question I mistakenly posted a property let procedure. It
would have been Property Get.
"Rob Bovey" wrote in message
...
Hi Ömer,

The TagName property is a single value, not an array. The way you have
it defined (which I think is what you want) is that the desired array

index
is passed in and the single value from that array is returned. In that

case
it should work if modified as follows:

Public Property Let TagName(ByVal intI As Integer)
TagName = ParsedData(intI)
End Property

This assumes that ParsedData is a valid array and that intI is a valid

index
into that array.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Ömer Ayzan" wrote in message
...
Dear friends,

I am trying to write a class that will parse XML data. I have a property
called TagName. Since there are many tags I wanted to index them. Even
though in the syntax of Property Get statement an argument can be used

when
I attempt to use the following code I get an "Compile error: Can't

assign
to
read-only property." error.

Public Property Let TagName(ByVal intI As Integer)
TagName(intI) = ParsedData(intI)
End Property
Any suggestions are appreciated
Ömer Ayzan







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Property Get with argument

Hi Rob,

I worked that way. My mistake was to try to dimension the TagName property.

Thanks alot,

Ömer


"Rob Bovey" wrote in message
...
Hi Ömer,

Even knowing that you're trying to create a property Get, I'm not sure
what the problem is. Let me propose a very basic example based on what

your
original code:

---------
In Class1
---------
Option Explicit

Private ParsedData() As String

Private Sub Class_Initialize()
Dim lCount As Long
ReDim ParsedData(1 To 10) As String
For lCount = 1 To 10
ParsedData(lCount) = "Item " & CStr(lCount)
Next lCount
End Sub

Public Property Get TagName(ByVal intI As Integer)
TagName = ParsedData(intI)
End Property

-------------
In Module 1
-------------
Sub Test()
Dim clsTest As Class1
Set clsTest = New Class1
Debug.Print clsTest.TagName(3)
Set clsTest = Nothing
End Sub

Running the Test sub prints out the value "Item 3" in the immediate

window,
which is what I would expect. What is the conceptual difference between

this
code and what you're trying to do in your application?

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Ömer Ayzan" wrote in message
...
Rob thank you for your answer.
Actually I have a parse method which finds out how many tags there are
within the file opened and then loads them into a 1 by n array. In the

first
dimension the tag name is kept, and in the second the tag value. TagName

and
TagValue are read only properties. So I can't use a property let

statement.
Do you think I should use a collection?

Thanking in advance.
Ömer

"Rob Bovey" wrote in message
...
Hi Ömer,

The TagName property is a single value, not an array. The way you

have
it defined (which I think is what you want) is that the desired array

index
is passed in and the single value from that array is returned. In that

case
it should work if modified as follows:

Public Property Let TagName(ByVal intI As Integer)
TagName = ParsedData(intI)
End Property

This assumes that ParsedData is a valid array and that intI is a valid

index
into that array.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Ömer Ayzan" wrote in message
...
Dear friends,

I am trying to write a class that will parse XML data. I have a

property
called TagName. Since there are many tags I wanted to index them.

Even
though in the syntax of Property Get statement an argument can be

used
when
I attempt to use the following code I get an "Compile error: Can't

assign
to
read-only property." error.

Public Property Let TagName(ByVal intI As Integer)
TagName(intI) = ParsedData(intI)
End Property
Any suggestions are appreciated
Ömer Ayzan











Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I Need An Argument newdeas Excel Worksheet Functions 4 July 20th 08 05:27 PM
Can I use the argument: - IF, AND, THEN, ElSE Newie New Users to Excel 2 June 14th 07 01:49 PM
if argument? Struggling of Essex Excel Discussion (Misc queries) 6 December 31st 05 09:48 AM
One more Argument. Steved Excel Worksheet Functions 1 July 28th 05 08:55 AM
IF THEN argument Julie Holeman Excel Discussion (Misc queries) 3 January 26th 05 04:22 PM


All times are GMT +1. The time now is 04:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"