Results 1 to 5 of 5

Thread: Boolean help [Resolved]

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    17

    Resolved Boolean help [Resolved]

    I'm trying to make a boolean for playerX...looks like this, it's tic tac toe by the way...

    VB Code:
    1. dim playerX as boolean
    2. dim Playerturn as boolean
    3. ...
    4. ...
    5. ...
    6. if(playerX = true) & (playerturn = true) then
    7. button1.text = "X"
    8. elseif (PlayerX = false) & (Playerturn = true) then
    9. button1.text = "O"
    10. Else
    11. button1.text = "err"

    i get an error once i click on the button...i'll show the exact error message below... :






    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.

    ************** Exception Text **************
    System.InvalidCastException: Cast from string "FalseFalse" to type 'Boolean' is not valid. ---> System.FormatException: Input string was not in a correct format.
    at Microsoft.VisualBasic.CompilerServices.DoubleType.Parse(String Value, NumberFormatInfo NumberFormat)
    at Microsoft.VisualBasic.CompilerServices.BooleanType.FromString(String Value)
    --- End of inner exception stack trace ---
    at Microsoft.VisualBasic.CompilerServices.BooleanType.FromString(String Value)
    at gametest.MainForm.Button1Click(Object sender, EventArgs e) in C:\Documents and Settings\Owner\My Documents\SharpDevelop Projects\gametest\MainForm.vb:line 214
    at System.Windows.Forms.Control.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ButtonBase.WndProc(Message& m)
    at System.Windows.Forms.Button.WndProc(Message& m)
    at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


    ************** Loaded Assemblies **************
    mscorlib
    Assembly Version: 1.0.5000.0
    Win32 Version: 1.1.4322.573
    CodeBase: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
    ----------------------------------------
    gametest
    Assembly Version: 1.0.2056.17014
    Win32 Version: 1.0.2056.17014
    CodeBase: file:///C:/Documents%20and%20Settings/Owner/My%20Documents/SharpDevelop%20Projects/gametest/bin/Debug/gametest.exe
    ----------------------------------------
    System.Windows.Forms
    Assembly Version: 1.0.5000.0
    Win32 Version: 1.1.4322.573
    CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
    ----------------------------------------
    System
    Assembly Version: 1.0.5000.0
    Win32 Version: 1.1.4322.573
    CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
    ----------------------------------------
    System.Drawing
    Assembly Version: 1.0.5000.0
    Win32 Version: 1.1.4322.573
    CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
    ----------------------------------------
    Microsoft.VisualBasic
    Assembly Version: 7.0.5000.0
    Win32 Version: 7.10.3052.4
    CodeBase: file:///c:/windows/assembly/gac/microsoft.visualbasic/7.0.5000.0__b03f5f7f11d50a3a/microsoft.visualbasic.dll
    ----------------------------------------

    ************** JIT Debugging **************
    To enable just in time (JIT) debugging, the config file for this
    application or machine (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging
    enabled.

    For example:

    <configuration>
    <system.windows.forms jitDebugging="true" />
    </configuration>

    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the machine
    rather than being handled by this dialog.
    Last edited by xpertsword; Aug 18th, 2005 at 10:27 AM.

  2. #2
    Hyperactive Member The_Duck's Avatar
    Join Date
    May 2005
    Location
    Leamington, UK
    Posts
    351

    Re: Boolean help

    Let me say arg!

    & is a string append in vb.net !

    USE And (or AndAlso, Or, OrElse!)

  3. #3
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Boolean help

    Yeah, the clue was "FalseFalse" in the second line of that looooooooong error message.
    I don't live here any more.

  4. #4
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Boolean help

    VB Code:
    1. dim playerX as boolean
    2. dim Playerturn as boolean
    3. ...
    4. ...
    5. ...
    6. if playerX and playerturn then
    7. button1.text = "X"
    8. elseif not PlayerX and Playerturn then
    9. button1.text = "O"
    10. Else
    11. button1.text = "err"
    I don't live here any more.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    17

    Re: Boolean help

    so basically i'm supposed to use 'And' instead of '&' ?

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