If InStr(currentoption,"INTUM")>0 Or InStr(currentoption,"SHIM")>0 Then
MsgBox "INSTALLER SHIM ET/OU INTUMESCENT ( VOIR W.O. ET CARTABLE INSTRUCTION INSTALLATION DE SHIM ET INTUMESCENT.)" ,vbExclamation
End If
everytime we have this option in the program it creates multiple msgbox pop ups as it reads all the lines. Is there a way to eliminate that . Please ask me if you need more information. I am really a beginner with this language and trying to learn own my own.
Like @LesFerch suggested, you can create a variable that tracks if the warning has been shown or not. You initialize it as False and then, after showing the warning, you set it to True. Before displaying the warning (
MsgBox), check the state of that variable to see if the warning has already been displayed:Going further, you can also give the user the option to cancel out of the line-reading loop so they can immediately fix the problem that triggers the warning. This is done by displaying Yes/Cancel buttons on the message box using
vbOKCancelin addition tovbExclamation. Once the user has clicked Yes or Cancel, the button they clicked will be saved in theiUserResponsevariable. You can then check if they clicked Cancel and exit your loop. In this sample, I created a simpleForloop that goes from 1 to 10 to demonstrate how I would exit that loop. I displayiLineCounterat the end of the loop to demonstrate that if you click OK, the loop will complete its 10 iterations but if you hit Cancel, it will exit right away (iLineCounterwill be 1).