VBA Excel 2010 Editor capitalizes property name and it cannot be accessed -



VBA Excel 2010 Editor capitalizes property name and it cannot be accessed -

as response post, server returns simple json object can indicate success or failure of upload.

the json object can either {config_version:n} indicate success or {exception:reason} indicate failure.

i process response in next manner:

json = objhttp.responsetext set sc = createobject("scriptcontrol") sc.language = "jscript" set o = sc.eval("(" + json + ")") on error goto exception: ' seek utilize config_version property util.setconfigdata "version", o.config_version exit function exception: if o.exception = "config_not_valid" ' 1 kind of exception - accordingly else ' kind of exception end if

the problem facing vba excel 2010 editor capitalizing o.exception o.exception! in watch window see property exception cannot access it. how can forcefulness editor stop capitalizing property name? there other syntax accessing properties in vba?

edit: improve illustrate happening here 2 screen shots.

as can see, o has property called exception. when trying access o.exception triggers 438 error.

since have command on backend, changed response homecoming {exception:whatever} (cannot permanently). vba has no problem picking property.

how possible if vba compiler case-insensitive suggested jean-françois corbett?

this wierd. can lower-case "e" stick in tester(), if alter declaration of "exception" in test2() "exception", the vbe automatically changes changes instances in tester() "exception". changing "exception" has reverse effect.

basically need create sure you're not using "exception" anywhere else in project.

sub tester() dim sc, o set sc = createobject("scriptcontrol") sc.language = "jscript" set o = sc.eval("({exception:'blahblah'})") debug.print o.exception 'prints blahblah end sub sub test2() dim exception string exception = "blah" end sub

edit:

if you're still stuck can seek way, leaving parsed json object in script command instance:

set sc = createobject("scriptcontrol") sc.language = "jscript" sc.eval "var o = eval({exception:'blahblah',message:'oops'})" debug.print sc.eval("o.exception") 'prints blahblah debug.print sc.eval("o['exception']") 'same thing... debug.print sc.eval("o.message") 'prints oops

excel vba excel-vba

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -