Results 1 to 7 of 7

Thread: [RESOLVED] Boolean problem

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    Resolved [RESOLVED] Boolean problem

    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

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Boolean problem

    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

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Boolean problem

    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?

  4. #4
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: Boolean problem

    In some cases you need a tristate values: True, False or Unknown (not sure that is True or False).
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

  5. #5
    Cumbrian Milk's Avatar
    Join Date
    Jan 2007
    Location
    0xDEADBEEF
    Posts
    2,448

    Re: Boolean problem

    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
    W o t . S i g

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2009
    Posts
    573

    Re: Boolean problem

    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

  7. #7
    PowerPoster
    Join Date
    Jun 2001
    Location
    Trafalgar, IN
    Posts
    4,141

    Re: Boolean problem

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width