Changing YES AND NO VALUES

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dave1816
    New Member
    • Nov 2007
    • 4

    Changing YES AND NO VALUES

    i got to hand my assigment in tomorrow on VB .NET all i basicly want to know is if their is anyway you can change the yes and no values. This would make my life so much easyer if you can! So i can have 1 and 0 instead of 6 and 7. Im sure my teacher told me it is possible but i cant seem to find anything on the web. if not ill post my complicated question and code tomorrow,lol

    Cheers

    Dave
  • vanc
    Recognized Expert New Member
    • Mar 2007
    • 211

    #2
    Originally posted by dave1816
    i got to hand my assigment in tomorrow on VB .NET all i basicly want to know is if their is anyway you can change the yes and no values. This would make my life so much easyer if you can! So i can have 1 and 0 instead of 6 and 7. Im sure my teacher told me it is possible but i cant seem to find anything on the web. if not ill post my complicated question and code tomorrow,lol

    Cheers

    Dave
    ??? What are you saying about??? Please make it clear so someone can help you out here mate.

    cheers.

    Comment

    • debasisdas
      Recognized Expert Expert
      • Dec 2006
      • 8119

      #3
      Are you retriving the values from database ?

      Comment

      • balabaster
        Recognized Expert Contributor
        • Mar 2007
        • 798

        #4
        Originally posted by vanc
        ??? What are you saying about??? Please make it clear so someone can help you out here mate.

        cheers.
        Sounds like you want to have the boolean values "yes" and "no" correspond with something other than 0 and 1 (although true seems to be represented by -1 these days instead of 1 which confuses things a little further). So you might want "yes" to equate to 6 instead of 1 and "no" to equate to 7?

        The only way I can think of off the top of my head is by using the MsgBoxResult... the Yes button corresponds with 6 and the No button corresponds with 7 (coincidentally )...are you referring to that?

        Try:

        Dim i As MsgBoxResult =

        scroll through the intellisense list - it will tell you what each different button corresponds to. Unfortunately it doesn't actually change the boolean values of True = 6 and False = 7...but you can store the values numerically effectively mimicking the effect you're looking for.

        Comment

        • balabaster
          Recognized Expert Contributor
          • Mar 2007
          • 798

          #5
          Originally posted by balabaster
          Sounds like you want to have the boolean values "yes" and "no" correspond with something other than 0 and 1 (although true seems to be represented by -1 these days instead of 1 which confuses things a little further). So you might want "yes" to equate to 6 instead of 1 and "no" to equate to 7?

          The only way I can think of off the top of my head is by using the MsgBoxResult... the Yes button corresponds with 6 and the No button corresponds with 7 (coincidentally )...are you referring to that?

          Try:

          Dim i As MsgBoxResult =

          scroll through the intellisense list - it will tell you what each different button corresponds to. Unfortunately it doesn't actually change the boolean values of True = 6 and False = 7...but you can store the values numerically effectively mimicking the effect you're looking for.
          Having come back to revisit this...it occurs to me that you may have wanted the yes and no buttons to equal 1 and 0 instead and not the other way around...I'm pretty sure the only way to do this would be something like this:
          VB
          Code:
          Dim Result As Boolean = (MsgBox("This is stuff", MsgBoxStyle.YesNo) = MsgBoxResult.Yes)
          C#
          Code:
          bool Result = (MessageBox.Show("This is stuff", MsgBoxStyle.YesNo) == MsgBoxResult.Yes);
          This would effectively convert the answer from a YesNo message box to True/False or -1/0.

          I'm pretty sure the MsgBox/MessageBox class is not inheritable so I can't think of another way you can do it...not to say there isn't one.

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            Quick fix:

            C#
            Code:
            bool Result = (MessageBox.Show("this is text", "this is caption", MessageBoxButtons.YesNo) == DialogResult.Yes);

            Although, we're not supposed to help with assignments.

            Comment

            • balabaster
              Recognized Expert Contributor
              • Mar 2007
              • 798

              #7
              Originally posted by Plater
              Quick fix:

              C#
              Code:
              bool Result = (MessageBox.Show("this is text", "this is caption", MessageBoxButtons.YesNo) == DialogResult.Yes);

              Although, we're not supposed to help with assignments.
              Thanks for the fix...oversight on my part. Not even really sure that was what the question was about. He never confirmed...so I'm just answering assumptions. :oP

              Comment

              • Plater
                Recognized Expert Expert
                • Apr 2007
                • 7872

                #8
                Originally posted by balabaster
                Thanks for the fix...oversight on my part. Not even really sure that was what the question was about. He never confirmed...so I'm just answering assumptions. :oP
                According to the OP their project was due by "today" so they probably never came back

                Comment

                • balabaster
                  Recognized Expert Contributor
                  • Mar 2007
                  • 798

                  #9
                  Originally posted by Plater
                  According to the OP their project was due by "today" so they probably never came back
                  I always wonder about people who leave their assignments to the last minute like that. How do they ever expect to pass if they haven't taken the effort to know the fundamentals the night before the assignment is due?

                  Comment

                  Working...