Greater than Less Than

Greater than Less Than

layochim
Enthusiast Enthusiast
144 Views
5 Replies
Message 1 of 6

Greater than Less Than

layochim
Enthusiast
Enthusiast

Hello, I'm trying to create a statement for my conveyor heights.

I have two heights Infeed_End and Discharge_End.

 

I'm trying to write "If Discharge_End > 115 And Infeed_End < 25 Then Discharge_End = 114 And Infeed_End = 26"

 

I'm having no luck on this.  Can anyone help me on this?

0 Likes
Accepted solutions (1)
145 Views
5 Replies
Replies (5)
Message 2 of 6

machiel.veldkamp
Collaborator
Collaborator

The if statement cannot modify two parameters in one line. 

You have to break it up like this

 

If (Discharge_End > 115) And (Infeed_End < 25) Then 
	Discharge_End = 114 
	Infeed_End  = 26
End If
	

 

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

___________________________
0 Likes
Message 3 of 6

layochim
Enthusiast
Enthusiast

That Worked! Thank you! Would i be able to add a third condition?  Such as the Belt Length to this statement or would i need to use a different function?

0 Likes
Message 4 of 6

machiel.veldkamp
Collaborator
Collaborator
Accepted solution
If ((Discharge_End > 115) And (Infeed_End < 25) ) Or (Belt_Length = 200) Then 
	Discharge_End = 114 
	Infeed_End  = 26
End If

This makes it that if the Discharge_end reaches above 115 + Infeed_End is below 25 stuff will happen 

 

OR 

 

if the Belt_Length is the exact length of 200.

 

You can play with it of course. 

 

 

So an if statement looks for a 'true' value to actually do stuff right?

 

Example:

If Statement = True 

      DoStuff

End if

 

You can also look for an other value that, when ultimitly combines to 'true' then it will do stuff..

 

Below here.... 2 'trues' make one giant 'true'

 

If (Statement = True) AndIf (OtherStatement = True)

      DoStuff

End if

 

Here's some more text for you to read from microsoft. 


https://learn.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/if-then-else-sta...

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

___________________________
0 Likes
Message 5 of 6

layochim
Enthusiast
Enthusiast

This is great, thank you for the explanation, very helpful!

Message 6 of 6

machiel.veldkamp
Collaborator
Collaborator

You're welcome! Have fun!

Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

___________________________
0 Likes