How to Use VB Scripting to Identify Completion of Tests with Empty Cells

Question:

Hello there, I am seeking a way for my system to identify when all tests have been completed. I am considering having the user input a "#" symbol to indicate the end of tests, with the system then alerting the user. The system should display a message on the HMI before the user confirms test initiation, with a blank cell also being acceptable instead of a null value. I am unsure how to incorporate this functionality into the "read data" code provided in the attachment. The process involves: 1. Users entering up to 5 test runs in an Excel spreadsheet. 2. HMI reading the spreadsheet, displaying it on the screen, and storing the data for the PLC. 3. Tests being conducted sequentially. 4. Recording data in an Excel file once a test is completed (noting temperature and torque). 5. Alerting the user when the "#"/blank cell is received to signify the completion of all tests. Thank you in advance for any assistance!

Top Replies

To check if the temp_n variants are empty, you can compare them to a null value in the code. For example, you can use the following code snippet: IF temp_5 = "", the PLC may still need to determine if test 5 is missing. One option is to assign a nonsensical value like -999.0 to the temperature or torque. In this scenario, the PLC will halt when encountering such a value. Additionally, there could be a hidden "torque_6" equivalent in the PLC with a constant value of -999.0, ensuring that the PLC always encounters -999.0 at some point, even if all five tests have valid values.

The presence of a blank text or a '#' in any of the 5 cells signifies the end of the test sequence. Utilize zero values and set limits on the tag to trigger color animations in the cell, indicating the limit. To enhance clarity, monitor cell values in the PLC and use them to control a dynamic text list displaying messages like '5 tests are pending', '4 tests are pending', '1 test is pending', or 'no more tests are pending'. This approach is more effective than relying on implicit meanings. If displaying a blank field instead of '0' is desired for operators, various methods can achieve this, such as visibility and color animations. No scripts are necessary for this process.

There are various methods for determining if a cell is blank in Excel. One way is to test the tags in the HMI or PLC for an empty cell. Another approach is to iterate through the cells in Excel and use the ISBLANK function. By populating a specific cell with a check character or the number of tests, you can use this information in the HMI or PLC. For example, Cell A7 can store the number of tests conducted. This allows for efficient data management and integration between Excel and the HMI/PLC systems.

Hello, I appreciate your responses! I have combined suggestions from @parky and @drbitboy and made some changes to the code. However, I am encountering a syntax error and I need help resolving it. It has been a while since I last used VB scripting, about 10 years ago in school, so I'm struggling to pinpoint the issue. Can anyone assist me in identifying and resolving the error in the code?

When specifying the type, consider using DIM tagnames (1 to 10) As String. However, it may be more appropriate to use DIM tagnames (10) As String upon further consideration.

You're on the right track with using a symbol or a blank cell to indicate the end of tests. However, you'll need to modify your "read data" code to recognize this symbol or blank cell as a command to end the testing. Since the system is already effectively communicating with the Excel spreadsheet, you can add a simple conditional statement in your code to check for the "#" symbol or a blank cell after each test is run. When the conditional comes true, script the system to trigger an alert for the user. Also, if you decide to default a blank cell as an end test indication, ensure there won't be any 'accidental' blank cells which might prematurely signal the end. Good luck!

Your plan sounds well-organized and pretty thorough. However, relying on users to indicate that tests are completed via a '#' may not be the most efficient or reliable method. Rather than relying on user input alone, why not automatically signal test completion based on the data recorded in your Excel file? For implementation, you could have your code read the Excel file, checking for new test data after each test run. If none is found, it could trigger the end-of-tests alert you mentioned. Plus, the issue of a null value or a blank cell would be intrinsically solved, as an absence of new data would equate to the end signal. This way, the process could be more autonomous and less prone to human error.

More Replies →

Streamline Your Asset Management
See How Oxmaint Works!!

✅   Work Order Management

✅   Asset Tracking

✅   Preventive Maintenance

✅   Inspection Report

We have received your information. We will share Schedule Demo details on your Mail Id.

To add a comment, please sign in or register if you haven't already..   

Frequently Asked Questions (FAQ)

FAQ: 1. How can I use VB Scripting to identify the completion of tests with empty cells or a "" symbol?

Answer: - You can achieve this functionality by implementing a check in your VB Scripting code to look for either an empty cell or a "" symbol to indicate the completion of tests.

FAQ: 2. Can the system display a message on the HMI before the user confirms test initiation?

Answer: - Yes, you can include code in your VB Scripting to display a message on the HMI before the user confirms test initiation.

FAQ: 3. How can I modify the provided "read data" code to incorporate the functionality of identifying test completion?

Answer: - To modify the "read data" code to incorporate the functionality of identifying test completion, you can add conditional statements to check for the presence of "" symbol or empty cells.

FAQ: 4. Is it possible to have a blank cell instead of a null value to signify the end of tests?

Answer: - Yes, you can configure your VB Scripting to accept a blank cell as a valid indicator of test completion in addition to the "" symbol.

FAQ: 5. How can I record data in an Excel file once a test is completed, noting temperature and torque?

Answer: - You can enhance your VB Scripting code to write data to an Excel file once a test is completed, capturing information such as temperature and torque for each test run.

Ready to Simplify Maintenance?

Join hundreds of satisfied customers who have transformed their maintenance processes.
Sign up today and start optimizing your workflow.

Request Demo  â†’