Author Topic: Getting element by ID from Repository in Visual Basic script end with an error  (Read 11526 times)

Lukas

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Hi there,
I am trying to get an element by its id
Code: [Select]
dim element as EA.Element
element = Repository.GetElementByID(someID)
but I get error:
object doesn't support property or method
The same code but in javascript works as charm. Can you guide me how to get an element by id in Visual Basic script?

Why I am not writing the script in javascript if it works? correct me if I am wrong but you can not update use case constraint notes in javascript. If you want to update use case constraint you have to create new one, delete old one because you can not just asssing new value (there is not setAt function only getAt)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
IIRC in VB the braces are fairy dust. Try to leave them away here.
Code: [Select]
element = Repository.GetElementByID someID
Not sure, though and I would never touch VB if not forced too. This isn't a programming language. It's a bad joke.

q.

Lukas

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Ok now I got end of statement expected

Edit
OK I got this. You can use braces but you have to use set word. So the sentence looks like this
Code: [Select]
set element = Repository.GetElementByID(someID)
Thank you for your help :)
« Last Edit: November 21, 2021, 12:12:30 am by Lukas »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13286
  • Karma: +556/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Hi there,
I am trying to get an element by its id
Code: [Select]
dim element as EA.Element
element = Repository.GetElementByID(someID)
but I get error:
object doesn't support property or method
The same code but in javascript works as charm. Can you guide me how to get an element by id in Visual Basic script?

Why I am not writing the script in javascript if it works? correct me if I am wrong but you can not update use case constraint notes in javascript. If you want to update use case constraint you have to create new one, delete old one because you can not just asssing new value (there is not setAt function only getAt)
You are wrong  ;D
VBScript and Javascript use exactly the same API. Anything you can do with javascript you can do with VBScript.

Geert

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13286
  • Karma: +556/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
IIRC in VB the braces are fairy dust. Try to leave them away here.
Code: [Select]
element = Repository.GetElementByID someID
Not sure, though and I would never touch VB if not forced too. This isn't a programming language. It's a bad joke.

q.
It's even weirder. If you are using the returned value, you have to use parentheses. If you don't use the returned value (or there isn't any) then you are not allowed to use bracket.

"Set" is used if setting an object. For primitives such as string, you must leave Set out.

Geert