Populating DataEntryRegions in a cell from VBA textbox

Hello everyone,

This is my first post on Be Communities, so if anything is wrong do not judge me very strictly.. I was browsing this great website for over a week now trying to find a solution to my problem, but still seem to be stuck on it...

I work for a company who uses Microstation V8 XM Edition to design railway signalling systems and they asked me (IT guy) to produce a macro which would enable them to save time and reduce number of mistakes.

Ok, here is my problem. I got a user interface created in VBA and i got three textboxes. User will need to input data into these boxes and then by pressing "Process" button macro shall populate particular cells in .dgn file with info from textboxes. Each cell has 5 DataEntry Regions so I need to use them.

Name of a whole cell is: UP_EDF.

The problem is that I'm a complete newbie with Microstation and cannot really workout how to do it. I do have experience working with VB.

I was able to find like a guide which one of Be Community's members posted:

1. Get Cell Element.
2. Enumerate over the contents of the cell using CellElement.MoveToNextElement
3. For each TextElement encountered, determine if it has DataEntryRegions and how many (TextElement.DataEntryRegionsCount).
   Each TextElement can have 0 or more EDFields. You will want to keep track of which EDField you want to populate. For example, if you have 2 TextElements with 2 EDFields each, then to populate EDField number 3 in the entire cell, you would want the first EDField in the second Text Element.
4. Once you have the desired TextElement then you would grab a copy of it from the Cell Enumerator using CellElement.CopyCurrentElement.
5. Populate the desired EDField(s) using TextElement.DataEntryRegionText(idx)=newText.
6. Then you would update the TextElement in the cell by writing back with CellElement.ReplaceCurrentElement <updated TextElement>

But it is not really taking me very far...

I have also attached a picture of a cell I'm trying to update. I would really appreciate your help.

Thank you guys in advance.

Parents
  • The purpose of data entry fields is to make is easy for a user to put text in the right place.  They are a hangover from MicroStation's predecessor IGDS.

    If you are in programmatic control of the data entry, as you are with your VBA UserForm, then the data entry fields are redundant.  Your VBA can do whatever it wants with the text the user enters.

    So forget the data entry fields.  When your user clicks OK, simply find each TextElement in the cell and replace it with the content of a TextBox on your UserForm.  From your screenshot I guess that you need to find what fields the user has already completed, then look for the next blank TextElement .

     
    Regards, Jon Summers
    LA Solutions

  • Jon, thanks for your reply.

    The thing is how to identify each cell using vba? As you can see from my attached image there are 5 DataEntryRegions in each cell. Do you know if it is possible to get a unique number of each DataEntryRegion? I know there are Element IDs of each cell which includes all 5 DataEntryRegions... I need to that  to be able to intelligently identify numbers in a particular DataEntryRegion in a future. You can see what I mean in a picture attached. For example if VERSION is KK5 at the moment VBA needs to scan that particular field and if KK5 is detected then program shall increment KK5 to KK6. I hope you understand what Im trying to say :)

    Or is it would be possible to specify in the code something like: ElementId: 2619 = textbox1.text?

    Your help is very appreciated :) Thank you very much.

  • andrejusk said:
    There are 5 DataEntryRegions in each cell

    It's hard to cell from a screenshot, but it looks to me that each cell has a single enter-data field five characters long.

    What we can't know from a screenshot is how that table is constructed.  We don't know if it's one big cell, with gridlines to demarcate columns and rows, or if it's a stack of 3-column cells, or a 3x9 cell matrix.

    andrejusk said:
    For example if VERSION is KK5 at the moment

    Version identifies a column of cells.  Find the column that contains Version and search that column for the last cell that contains a non-blank TextElement.  Use the value in that cell to compute a new value that you update and use to set the TextElement in the following cell.

     
    Regards, Jon Summers
    LA Solutions

Reply
  • andrejusk said:
    There are 5 DataEntryRegions in each cell

    It's hard to cell from a screenshot, but it looks to me that each cell has a single enter-data field five characters long.

    What we can't know from a screenshot is how that table is constructed.  We don't know if it's one big cell, with gridlines to demarcate columns and rows, or if it's a stack of 3-column cells, or a 3x9 cell matrix.

    andrejusk said:
    For example if VERSION is KK5 at the moment

    Version identifies a column of cells.  Find the column that contains Version and search that column for the last cell that contains a non-blank TextElement.  Use the value in that cell to compute a new value that you update and use to set the TextElement in the following cell.

     
    Regards, Jon Summers
    LA Solutions

Children
No Data