I could not understand ur question, y would you need the code for master profibus, there are cards available for t hem. you just have to handle the output of that card. afterwards it is not that difficult. If you think I didn't understand ur question then plz say so.
Thank you.
On the page of Siemens www4.ad.siemens.de you may find a example under ID 7888239 "Sample programs for FMS, SR, S7, DP, DPS and FDL communications to an OPC server" or ID 11492750 "SIMATIC NET examples (DP, DP-Base for CP 5613, DP-C1, DP-C2, DP-MCL2, DP-Slave for CP 5x11, DPS-Base for CP 5614, FDL, FMS and S7) for Visual Basic".
These examples are put on top of the drivers that are on the market from Siemens.