hexagon logo

Writing/Reading a .txt file

This is very much a VB question not related to PC-DMIS. There is so much information out there for VB that I find it very hard to locate a good example of what I want to do.

I have a script at the beginning and end of my part program. I would like to get the total runtime of the program. I have a way to get systemtime in each and put it into seconds and such, thanks to this message board.

I do not want to write the beginning time to a variable and have it go through the part program. What I wanted was a temporary .txt file or something similar that I could write the begintime value (in seconds) to. The second script would grab this value and use it. The .txt file either needs to be cleared or overwritten by the new begintime number every execution. How do I code this?

My goal is to take these values and use them to calculate CMM run time for the day in Excel. Can I export the Total Runtime number I get in the second script to Excel? It will probably be easier to google information for this; I will update this post if I find what I am looking for.

Thanks!
  • Thanks very much, both of you. This has gotten me off the ground, much appreciated. Smiley
  • I am actually writing these scripts in the VB editor in Excel, and then testing them to make sure they run ok through PC-DMIS. I am aware some syntax is different, but I am not going too complex just yet, so crossing my fingers that I won't run into problems.


    Seems to be a little know fact, but the code you write in Excel can run on it's own if you dont use any excel specific stuff. Screw the clunky basic that is native to pcdmis. Create a text file, change the extension to .vbs and then paste your code into it. VB6 is native executable in winxp
  • I can't download VB6 at work here, the download fails due to our firewall.

    I am using the Excel editor mainly for testing my scripts. Being newly introduced to scripts, I was getting about a dozen error boxes when using my code in PC-DMIS after writing it solely in notepad. Blush

    This is very powerful stuff I am learning to do, however. The lady that was supposed to code all this stuff, including my VB frontend for PC-DMIS, hasn't been around in a couple of weeks. I think they might have fired her....Neutral face So there will be a lot more questions pertaining to writing a frontend in VB in the coming weeks! Smiley
  • I can't download VB6 at work here, the download fails due to our firewall.

    I am using the Excel editor mainly for testing my scripts. Being newly introduced to scripts, I was getting about a dozen error boxes when using my code in PC-DMIS after writing it solely in notepad. Blush

    This is very powerful stuff I am learning to do, however. The lady that was supposed to code all this stuff, including my VB frontend for PC-DMIS, hasn't been around in a couple of weeks. I think they might have fired her....Neutral face So there will be a lot more questions pertaining to writing a frontend in VB in the coming weeks! Smiley



    If you are looking to do a PCD front end you probably need to have someone figure out how to get VB through your filrewall. The tools in there will help you even more than what is available in Excel, IMO. Also when you get a solution that you like you can compile it and "lock" it from accidental changes down the road. Microsoft makes a lot of their programming tools available in an Express (read free) edition now so they are all out there for the casual plunker like me....