Using Visual Basic (String-type Array and the “_HMI_CurrentPage” System Variable) This method combines the “_HMI_CurrentPage” system variable with the user-defined String-type array variable. It directly links the page numbers with the array’s element numbers and switches to the page number that corresponds with the contents of the array variable. 1. Declare on the NJ side a Numerical-type variable to store page numbers, and a String-type array variable. For the number of elements of the String-type array variable, specify the value greater than the number of pages. 2. Enter the names of the pages as the initial values of the String-type array variable.
Beware that you must modify this field if the page names are changed later. 3. Allocate on the NA side the variables declared in Step 1. Then, declare the variable to store page numbers. 4. In the global subroutine, write the code as shown on the right. By specifying the variable indicating the page number in the position for the element number of the String-type array variable, the screen is switched to the one that corresponds to the page number. 5. In the [Global Events] tab page, specify the conditions to execute the code. The figure on the right shows that the code created in Step 4 is executed every 100 msec. 6.
Changing the “PageNumber” NJ variable switches the screen to the page that has been registered as an initial value for the array variable created in Step 2. Example: When “2” is entered, the screen is switched to Page2. 43