ActiveModelReference.GetElementByID(DLongAdd(IDholder, DLongFromLong(1)))

Hi,

I am new to VBA Microstation and i have tried researching what this means but i still don't understand it fully, can someone please explain to a BEGINNER what this line means? i really need to understand this line of code to finish a macro for work.

Set target = ActiveModelReference.GetElementByID(DLongAdd(IDholder, DLongFromLong(1)))

 

Thank You

Parents
  • Hi,

    I don't like this shortened code, because it's harder to read it and undestand. But the function is quite simple at this case:

    • GetElementByID returns element from active model, identified by ID (every element in DGN has own unique ID).
    • ElementId is 64bit number, but VBA engine doesn't know 64bit integer, so MicroStation VBA uses own data type called DLong, which is 64bit integer.
    • What DLongAdd method does you can find in MicroStation VBA help file: It returns DLong as the sum of two another DLongs (IDholder and 1 in this case). What is the reason of this you have to ask an author of the code.
    • DLongFromLong(1) creates DLong from 1, which is integer. Because VBA doesn't know DLong, you have to use some from conversion functions to define value of DLong variable. Again, DLongFromLong is described in MicroStation VBA help.

    So on the whole, it doesn't do anything else that it sums two numbers and element with this ElementId value is returned.

    With regards,

      Jan

    With regards,

      Jan

    Answer Verified By: kevindragonduong 

Reply
  • Hi,

    I don't like this shortened code, because it's harder to read it and undestand. But the function is quite simple at this case:

    • GetElementByID returns element from active model, identified by ID (every element in DGN has own unique ID).
    • ElementId is 64bit number, but VBA engine doesn't know 64bit integer, so MicroStation VBA uses own data type called DLong, which is 64bit integer.
    • What DLongAdd method does you can find in MicroStation VBA help file: It returns DLong as the sum of two another DLongs (IDholder and 1 in this case). What is the reason of this you have to ask an author of the code.
    • DLongFromLong(1) creates DLong from 1, which is integer. Because VBA doesn't know DLong, you have to use some from conversion functions to define value of DLong variable. Again, DLongFromLong is described in MicroStation VBA help.

    So on the whole, it doesn't do anything else that it sums two numbers and element with this ElementId value is returned.

    With regards,

      Jan

    With regards,

      Jan

    Answer Verified By: kevindragonduong 

Children