0

Hi

I have an if statement which checks if a value has been entered and if it hasnt it pops up with a message box and tells the user.

Now if the if statement is in the same Sub as the code that is executing it works fine, but if i put it into a seperate sub and call it from within the original sub it still executes the original code:

If AppVariables.CustName = "" Then
            MsgBox("You have to configure this report before it can be run." & (Chr(13)) & (Chr(10)) & "Go to Configuration > Configure to resolve this", MsgBoxStyle.Critical)
            Return
        End If

Now since i have put it into the seperate sub and the ok/cancel button is pressed it still continues with the rest of the code and of course fails as not all information has been entered.

I wondered if anyone could help

Regards

3
Contributors
5
Replies
9
Views
9 Years
Discussion Span
Last Post by Jx_Man
0

Hey maybe u could try running a select case?
or u could try making a function procedure?
BTW I think "Go to Configuration > Configure to resolve > should be changed to an underscore _
from what I understand in vb.net so far > is greater than sighn

0

hi

the problem isnt with the logic of the if statement, its the stopping of the code if the the string is empty when it is being called from a different procedure e.g

Public Sub CheckValues()

        If AppVariables.CustName = "" Then
            MsgBox("You have to configure this report before it can be run." & (Chr(13)) & (Chr(10)) & "Go to Configuration > Configure to resolve this", MsgBoxStyle.Critical)
            Return
        End If

    End Sub



Public sub maincode()

call checkvalues()  ' Check to see if text has been entered into the variables


*****Run main code here


End Sub

now if the string is empty in 'checkvalues' it does return but by returning it still continues with the originating sub, how can i get it to stop doing that?

many thanks

0

u want after error message shown and button ok pressed the task will stopped?
try this code :

If AppVariables.CustName = "" Then
      If (MsgBox("You have to configure this report before it can be run." & (Chr(13)) & (Chr(10)) & "Go to Configuration > Configure to resolve this", MsgBoxStyle.Critical)) = MsgBoxResult.OK Then
                ' do what ever to stop...
      End If
End If
0

sorry i dont really follow - the checking code is called by the main procedure. so i have got the logic working fine in the check but how do i get it to stop running the procedure that called it?

kind regards

0

Public sub maincode()

call checkvalues() ' Check to see if text has been entered into the variables

*****Run main code here

End Sub

you mean other code below it (procedure calling) not executed?
just modified it :

Public sub maincode()

If AppVariables.CustName = "" Then
     MsgBox("You have to configure this report before it can be run." & (Chr(13)) & (Chr(10)) & "Go to Configuration > Configure to resolve this", MsgBoxStyle.Critical)
Else   
      *****Run main code here
End If

End Sub

so you don't have to call Check procedure...

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.