Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Avi Avi is offline
external usenet poster
 
Posts: 29
Default Help with Evaluate/Eval

Hi,

Could someone please help me out implementing evaluate/eval function
in excel vba.

in the code snippet below, i am navigating through a collection object
and trying to find value of a item based on the key.

For i = 0 To objCollection.Length - 1
Key = "id"
strTemp = "objCollection(" & i & ")." & Key
msgbox Evaluate(Chr(34) & strTemp & Chr(34) )
Next i

Following message box returns text objCollection(o).id, but i want
this to be calculated and show me the actual value.

Thanks in advance.
-Avinash
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Help with Evaluate/Eval

Avi wrote :
Hi,

Could someone please help me out implementing evaluate/eval function
in excel vba.

in the code snippet below, i am navigating through a collection object
and trying to find value of a item based on the key.

For i = 0 To objCollection.Length - 1
Key = "id"
strTemp = "objCollection(" & i & ")." & Key
msgbox Evaluate(Chr(34) & strTemp & Chr(34) )
Next i

Following message box returns text objCollection(o).id, but i want
this to be calculated and show me the actual value.

Thanks in advance.
-Avinash


You need to specify an objCollection.Item(i) to return the value held
at position i. Specify objCollection.Key to return its value if not an
integer.

Also, not sure why you start your loop at zero to have to subtract 1 to
get the UBound of your counter...

For i = 1 To objCollection.Count

...where i is type Long so it matches .Count!

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default Help with Evaluate/Eval

In order to get started correctly...

A Collection is 1 based.
A Collection does not have a Length property.
A Collection does have a Count property.
--
Jim Cone
Portland, Oregon USA
http://www.mediafire.com/PrimitiveSoftware
(List Files XL add-in: finds and lists files/folders with hyperlinks)




"Avi"
wrote in message
...
Hi,

Could someone please help me out implementing evaluate/eval function
in excel vba.

in the code snippet below, i am navigating through a collection object
and trying to find value of a item based on the key.

For i = 0 To objCollection.Length - 1
Key = "id"
strTemp = "objCollection(" & i & ")." & Key
msgbox Evaluate(Chr(34) & strTemp & Chr(34) )
Next i

Following message box returns text objCollection(o).id, but i want
this to be calculated and show me the actual value.

Thanks in advance.
-Avinash



  #4   Report Post  
Posted to microsoft.public.excel.programming
Avi Avi is offline
external usenet poster
 
Posts: 29
Default Help with Evaluate/Eval

On Wednesday, April 11, 2012 10:19:07 AM UTC+5:30, Jim Cone wrote:
In order to get started correctly...

A Collection is 1 based.
A Collection does not have a Length property.
A Collection does have a Count property.
--
Jim Cone
Portland, Oregon USA
http://www.mediafire.com/PrimitiveSoftware
(List Files XL add-in: finds and lists files/folders with hyperlinks)




"Avi"
wrote in message
...
Hi,

Could someone please help me out implementing evaluate/eval function
in excel vba.

in the code snippet below, i am navigating through a collection object
and trying to find value of a item based on the key.

For i = 0 To objCollection.Length - 1
Key = "id"
strTemp = "objCollection(" & i & ")." & Key
msgbox Evaluate(Chr(34) & strTemp & Chr(34) )
Next i

Following message box returns text objCollection(o).id, but i want
this to be calculated and show me the actual value.

Thanks in advance.
-Avinash


Thanks for the reply guys. Sorry for the confusion, the collection I referred here is not the VBA collection object rather its a collection of HTML object as below

---
Code:
Set objCollection = m_IE.Document.getElementsByTagName("input")
---
Where m_IE is IE object.

What I am trying to do here is read each input tag present in HTML doc and compare with the defined properties in a dictionary object e.g.

---
Code:
Set oDict = New Dictionary
oDict.Add "id" , "SomeID"
oDict.Add "class" , "SomeClass"
'Have some more key value pairs
---
Now in order to compare, I have following code

---
Code:
Set objCollection = m_IE.Document.getElementsByTagName("input")
CountInput =   objCollection.Length 'Where objCollection.Length will contain number of input tags 
For i = 1 To CountInput  
  For Each Key In oDict.Keys
     If Key < "" Then
         If oDict(Key) = objCollection(i).Key Then  '#########PRBLEM LINE#######
              'Do something
         End If
     End If
  Next Key
Next i
---
Referring to problem line above, objCollection(i) returns me an HTML object. This object will have properties like id, class etc.
In order to compare the html object to my internal dict object i am trying to evaluate expressiono "objCollection(i).Key" at run time.
e.g. in the loop When oDict("id") = "SomeID" then objCollection(i).id should be calculated and "SomeID" should be compared against that.

PS: Sorry for the long post, but I just tried to elaborate on what I am trying to achieve.
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
eval of concatenate function not displaying results tony12345 Excel Discussion (Misc queries) 1 March 6th 09 05:25 PM
press F2 to eval a cell, no color & no highlight Peggy C Excel Discussion (Misc queries) 0 October 8th 08 04:15 PM
Excel equivalent to Eval function PatrickS Excel Programming 1 August 15th 07 11:54 AM
is there an Eval() in Excel VBA clara Excel Programming 5 May 10th 07 08:00 PM
Eval function with sum raffaello_ Excel Discussion (Misc queries) 0 May 31st 06 11:51 AM


All times are GMT +1. The time now is 06:58 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"