# if statements

• ### Question

• Sub town
If x = 1 And y = 1 then
TextWindow.Clear()
shop()
ElseIf x = 1 and (6 <= y > 1) then
townrandom()
endif
EndSub

ElseIf x = 1 and (6 < y > 1) then

im trying to make it so (1,2),(1,3),(1,4),(1,5),(1,6) get sub townrandom

• Edited by Wednesday, September 17, 2014 2:22 AM
Wednesday, September 17, 2014 1:29 AM

• Do you want to do this?

```Sub Town
If x = 1 And y = 1 Then
TextWindow.Clear()
Shop()
ElseIf x = 1 And (2 <= y And y <= 6) Then
TownRandom()
EndIf
EndSub```

Nonki Takahashi

Wednesday, September 17, 2014 3:18 AM
•   this doesnt work

If x = 1 and (6 <= y > 1) then
TextWindow.WriteLine("Town")
space()
endif

this works

If x =1 And y = 2 Then
TextWindow.WriteLine("Town")
space()
endif

• Marked as answer by Sunday, September 28, 2014 5:34 PM
Wednesday, September 17, 2014 3:51 AM
• Dinomute,

You cannot have < and > in one single comparison. You have to do If  1>y and y<=6 then

or as Nonki said: three comparisons with two AND's:   X=1 And y>1 And y<=6

Jan [ WhTurner ] The Netherlands

• Proposed as answer by Wednesday, September 17, 2014 9:40 AM
• Marked as answer by Sunday, September 28, 2014 5:34 PM
Wednesday, September 17, 2014 8:16 AM

### All replies

• Do you want to do this?

```Sub Town
If x = 1 And y = 1 Then
TextWindow.Clear()
Shop()
ElseIf x = 1 And (2 <= y And y <= 6) Then
TownRandom()
EndIf
EndSub```

Nonki Takahashi

Wednesday, September 17, 2014 3:18 AM
•   this doesnt work

If x = 1 and (6 <= y > 1) then
TextWindow.WriteLine("Town")
space()
endif

this works

If x =1 And y = 2 Then
TextWindow.WriteLine("Town")
space()
endif

• Marked as answer by Sunday, September 28, 2014 5:34 PM
Wednesday, September 17, 2014 3:51 AM
• Dinomute,

You cannot have < and > in one single comparison. You have to do If  1>y and y<=6 then

or as Nonki said: three comparisons with two AND's:   X=1 And y>1 And y<=6

Jan [ WhTurner ] The Netherlands

• Proposed as answer by Wednesday, September 17, 2014 9:40 AM
• Marked as answer by Sunday, September 28, 2014 5:34 PM
Wednesday, September 17, 2014 8:16 AM