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!
Parents
  • 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.

    Thanks for the suggestions, much appreciated, all.

    So, going off of what cmmguy was saying, I could export my information to a log file so that it looked something like: 200,9242009,350-51,. 200=runtime in seconds, 9242009=date, 350-51=part number, etc. etc. for however many fields I want. Should I end each bit of information with a common character or something to make it easier to sort when bringing it into excel? I don't know what will be easiest when I start to bring stuff into excel, I am going to attempt to do that today for the first time.
Reply
  • 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.

    Thanks for the suggestions, much appreciated, all.

    So, going off of what cmmguy was saying, I could export my information to a log file so that it looked something like: 200,9242009,350-51,. 200=runtime in seconds, 9242009=date, 350-51=part number, etc. etc. for however many fields I want. Should I end each bit of information with a common character or something to make it easier to sort when bringing it into excel? I don't know what will be easiest when I start to bring stuff into excel, I am going to attempt to do that today for the first time.
Children
No Data