At the line:
If OpcServerStrg = "ICONICS.IconicsOPCUAServer.V5" Then
if the value in the variable OpcServerStrg
is not equal to "ICONICS.IconicsOPCUAServer.V5"
then the code will loop again to the top of the For
loop and execute OpcServerStrg = OPCServerlist(i)
again. The Exit For
will not be seen.
When you say you step through this code
... is it possible that you have a breakpoint set on the line: OpcServerStrg = OPCServerlist(i)
, and you are clicking run (untill breakpoint) instead of clicking to single-step through the code?
Try setting a breakpoint at the line:
If OpcServerStrg = "ICONICS.IconicsOPCUAServer.V5" Then
then examine the value of OpcServerStrg
when the program reaches the breakpoint and stops.