Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Help with code

Help with code

Scheduled Pinned Locked Moved Visual Basic
helptutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JRay5659
    wrote on last edited by
    #1

    I am working on a program for tic tac toe. The program is using text boxes with click event so when the box is clicked it will populate with a X or O unless it is already populated. I have everything working except my subrotine which is called from the checkfor win to check for a tie. Here is the code I am trying to use to check for a tie. Can someone please help me with why this causes the program to crash and also how to fix this code. Sub checkfortie() If txtPosition1.Text <> "" And txtPosition2.Text <> "" & txtPosition3.Text <> "" And _ txtPosition4.Text <> "" And txtPosition5.Text <> "" And txtPosition6.Text <> "" _ And txtPosition7.Text <> "" And txtPosition8.Text <> "" And txtPosition9.Text <> "" Then Catwins += 1 End If End Sub

    R L 2 Replies Last reply
    0
    • J JRay5659

      I am working on a program for tic tac toe. The program is using text boxes with click event so when the box is clicked it will populate with a X or O unless it is already populated. I have everything working except my subrotine which is called from the checkfor win to check for a tie. Here is the code I am trying to use to check for a tie. Can someone please help me with why this causes the program to crash and also how to fix this code. Sub checkfortie() If txtPosition1.Text <> "" And txtPosition2.Text <> "" & txtPosition3.Text <> "" And _ txtPosition4.Text <> "" And txtPosition5.Text <> "" And txtPosition6.Text <> "" _ And txtPosition7.Text <> "" And txtPosition8.Text <> "" And txtPosition9.Text <> "" Then Catwins += 1 End If End Sub

      R Offline
      R Offline
      Roy Heil
      wrote on last edited by
      #2

      If txtPosition1.Text <> "" And txtPosition2.Text <> "" & txtPosition3.Text <> "" And _ The problem is with one of your ands. You mistakenly used an &, which tries to do a bitwise and instead of a logical and. (Mixing up your C/C#/C++ with your VB?) This type of thing is hard to catch. Your brain sees what it wants to see. Roy.

      J 1 Reply Last reply
      0
      • J JRay5659

        I am working on a program for tic tac toe. The program is using text boxes with click event so when the box is clicked it will populate with a X or O unless it is already populated. I have everything working except my subrotine which is called from the checkfor win to check for a tie. Here is the code I am trying to use to check for a tie. Can someone please help me with why this causes the program to crash and also how to fix this code. Sub checkfortie() If txtPosition1.Text <> "" And txtPosition2.Text <> "" & txtPosition3.Text <> "" And _ txtPosition4.Text <> "" And txtPosition5.Text <> "" And txtPosition6.Text <> "" _ And txtPosition7.Text <> "" And txtPosition8.Text <> "" And txtPosition9.Text <> "" Then Catwins += 1 End If End Sub

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Please post your error message on the forum.

        J 1 Reply Last reply
        0
        • R Roy Heil

          If txtPosition1.Text <> "" And txtPosition2.Text <> "" & txtPosition3.Text <> "" And _ The problem is with one of your ands. You mistakenly used an &, which tries to do a bitwise and instead of a logical and. (Mixing up your C/C#/C++ with your VB?) This type of thing is hard to catch. Your brain sees what it wants to see. Roy.

          J Offline
          J Offline
          JRay5659
          wrote on last edited by
          #4

          Thanks for catching my mistake. It was an oversight on my part and me not paying atttention. The program works like a charm now.

          1 Reply Last reply
          0
          • L Lost User

            Please post your error message on the forum.

            J Offline
            J Offline
            JRay5659
            wrote on last edited by
            #5

            Thanks the problem is already solved. I made a mistake and had a & instead of And.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups