3 Replies - 294 Views - Last Post: 25 May 2012 - 09:36 AM Rate Topic: -----

#1 belgarion262  Icon User is offline

  • Prince of all (2) Saiyans

Reputation: 163
  • View blog
  • Posts: 947
  • Joined: 25-October 09

Logic Failure

Posted 24 May 2012 - 04:38 PM

I've started writing a little rpg for fun and wrote some code to determine your class based on your highest stat.
However, every time, it tells me i'm a mage.

i've stepped through and even as it progresses through the if statements to return type as mage, it clearly says the lblInt.text is less then lblStr.text. yet it still continues through the if statement.

can anyone see anything obvious, or wish me to upload more of the code?

  If (lblInt.Text > lblStr.Text) Then
            If (lblInt.Text > lblAgi.Text) Then
                If lblInt.Text > lblChar.Text Then
                    type = "Mage"
                End If
            End If
        End If


cheers

Is This A Good Question/Topic? 0
  • +

Replies To: Logic Failure

#2 kojima100  Icon User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 66
  • Joined: 10-November 10

Re: Logic Failure

Posted 24 May 2012 - 05:03 PM

Try using Cint to make sure their isn't any type screw ups:


if cInt(lblInt.Text) > cInt(lblStr.Text) Then



Was This Post Helpful? 0
  • +
  • -

#3 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1055
  • View blog
  • Posts: 4,085
  • Joined: 02-July 08

Re: Logic Failure

Posted 24 May 2012 - 06:47 PM

CInt does not check for screw ups. Integer.TryParse does! How about a Select Case

Dim result As string = ""
Select Case <int> '<- your integer variable here
   Case Is > 10
      result = "Mage"
   Case Is > 6
      result = "Foo Master"
   'etc...
End Select

Was This Post Helpful? 1
  • +
  • -

#4 belgarion262  Icon User is offline

  • Prince of all (2) Saiyans

Reputation: 163
  • View blog
  • Posts: 947
  • Joined: 25-October 09

Re: Logic Failure

Posted 25 May 2012 - 09:36 AM

thanks for the replies guys.

i'll give them a go and get back to you
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1