morning
Boolean is for a true or false answer,what is i need a third answer
true or false or none of the above?
thanks
Printable View
morning
Boolean is for a true or false answer,what is i need a third answer
true or false or none of the above?
thanks
You have to use something else than a Boolean. If you use Integer, you can make -1 = True, 0 = False, 1 = None of the above
Why I suggest it this way is because Boolean True = -1 and False = 0. So you can add: Const NoneOfTheAbove = 1
Something is either true or not true i.e., false -
slightly true = false; kinda true = false
How can something be not true AND not false?
Anything but absolutely true is false.
What could a possible third answer be? :confused:
In some cases you need a tristate values: True, False or Unknown (not sure that is True or False).
This is getting kind of philosophical ('c'est ne pas une pipe') but I don't see why you can't have something like True, False and NotSetYet.
There is a Tristate enum in VBA... True, False, and UseDefault
Code:Dim a As VBA.VbTriState
Dim b As VBA.VbTriState
Dim c As VBA.VbTriState
a = vbTrue
b = vbFalse
c = vbUseDefault
Debug.? a; b; c
im trying to understand about tracking a image around the screen.
i use get distance and this ,,
this works pretty good but in the text.text if it ="" does it read that as nothing ?
Code:Private Sub checkup(upp As Boolean)
If Image1(0).Top > Image2(0).Top Then
upp = True
Else
upp = False
End If
End Sub
Private Sub checkdown(downn As Boolean)
If Image1(0).Top < Image2(0).Top Then
downn = True
Else
downn = False
End If
End Sub
Private Sub checkleft(leftt As Boolean)
If Image1(0).Left > Image2(0).Left Then
leftt = True
Else
leftt = False
End If
End Sub
Private Sub checkright(rightt As Boolean)
If Image1(0).Left < Image2(0).Left Then
rightt = True
Else
rightt = False
End If
End Sub
Private Sub figureitout(ydir As String)
Dim upp As Boolean
Dim downn As Boolean
Dim leftt As Boolean
Dim rightt As Boolean
Call checkup(upp)
If upp = True Then Text1.Text = "true": Text2.Text = "false"
Call checkdown(downn)
If downn = True Then Text2.Text = "true": Text1.Text = "false"
Call checkleft(leftt)
If leftt = True Then Text3.Text = "true": Text4.Text = "false"
Call checkright(rightt)
If rightt = True Then Text4.Text = "true": Text3.Text = "false"
If Text1.Text = "true" And Text2.Text = "false" And Text3.Text = "" And Text4.Text = "" Then ydir = down
If Text1.Text = "false" And Text2.Text = "true" And Text3.Text = "" And Text4.Text = "" Then ydir = up 'MsgBox "chase dir up"
If Text1.Text = "" And Text2.Text = "" And Text3.Text = "false" And Text4.Text = "true" Then ydir = Left 'MsgBox "chase dir left"
If Text1.Text = "" And Text2.Text = "" And Text3.Text = "true" And Text4.Text = "false" Then ydir = Right 'MsgBox "chase dir right"
If Text1.Text = "true" And Text2.Text = "false" And Text3.Text = "true" And Text4.Text = "false" Then ydir = downright 'MsgBox "chase dir downright"
If Text1.Text = "true" And Text2.Text = "false" And Text3.Text = "false" And Text4.Text = "true" Then ydir = downleft ' MsgBox "chase dir downleft"
If Text1.Text = "false" And Text2.Text = "true" And Text3.Text = "true" And Text4.Text = "false" Then ydir = upright ' MsgBox "chase dir upright"
If Text1.Text = "false" And Text2.Text = "true" And Text3.Text = "false" And Text4.Text = "true" Then ydir = upleft 'MsgBox "chase dir upleft"
End Sub
I would probably use something like this for getting the direction.Code:Private Function GetDirection() As String
Dim intDirection As Integer
'upp = True
If Image1(0).Top > Image2(0).Top Then
intDirection = intDirection + 1
End If
'downn = True
If Image1(0).Top < Image2(0).Top Then
intDirection = intDirection + 2
End If
'leftt = True
If Image1(0).Left < Image2(0).Left Then
intDirection = intDirection + 4
End If
'rightt = True
If Image1(0).Left < Image2(0).Left Then
intDirection = intDirection + 8
End If
Select Case intDirection
Case 1
GetDirection = "down"
Case 2
GetDirection = "up"
Case 4
GetDirection = "right"
Case 8
GetDirection = "left"
Case 5
GetDirection = "down and right"
Case 9
GetDirection = "down and left"
Case 6
GetDirection = "up and right"
Case 10
GetDirection = "up and left"
End Select
End Function