Link to home
Start Free TrialLog in
Avatar of ict-torquilclark
ict-torquilclark

asked on

Operation is not allowed in this context

Can anybody explain why I am getting the error in the title on the last lnie of the code below?

                    If datagridviewClients.Item(2, x).Value.ToString.ToUpper.Contains("HEATH") Then
                        Heath = True
                    Else
                        Heath = False
                    End If

                If Heath = True Then


It has baffled me....
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

which line is it?
can u post more code, like what Heat is? property?
did u implement asynchronous operations?
Avatar of ict-torquilclark
ict-torquilclark

ASKER

That is all the code that there is - apart from the "End If"

heath is just defined in the code abover as a boolean

Dim Heath as Boolean

The if then sets it to true or false

and then i get the error on the next if...
try this:

dim value as string
value = datagridviewClients.Item(2, x).Value.ToString()

  If value.ToUpper().Contains("HEATH") Then
                        Heath = True
                    Else
                        Heath = False
                    End If

                If Heath = True Then

Open in new window

I still get the same error.

The code is fine at assigning the true/false value to Heath. The error comes when evaluating it for the "If Health = True" line.
Do you have anything else in your program called 'Heath' like perhaps a procedure?

What exactly is the error message?
Doesn't solve the mystery, but you could just try
If Heath Then
ASKER CERTIFIED SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If Heath = True Then (Then what??) this is a syntax error I assume
Simply change the variable "Heath" to "booHeath" in your routine and try it again. Then you can rule out most of the suggestions above.