Greater than/lesser than mixup!

Results 1 to 2 of 2

Thread: Greater than/lesser than mixup!

  1. #1
    Join Date
    Dec 1969

    Default Greater than/lesser than mixup!

    PLEASE HELP ME! Right sorry about that, but this one&#039s driving me mad. The greater than and less than operators seem to be getting mixed up when ever I test against a number stored in an array.<BR><BR>Heres the code that doing it :<BR><BR>TempGold = CInt(Player(GoldInHand))<BR>If Amount &#060;= TempGold Then<BR> Player(GoldInHand) = Player(GoldInHand) - Amount<BR> If Amount &#060;= 4 Then<BR> Amount = Amount - 1<BR> Else<BR> Amount = Int(Amount - ((Amount/100) * Application("BankCharge")))<BR> End If<BR> Player(GoldInBank) = Player(GoldInBank) + Amount<BR> Session("PlayerStats") = Player<BR> Application("BankCharge") = 10<BR> Session("AreaDescription") = "GoldInHand : &#039" & Player(GoldInHand) & "&#039Amount : &#039" & Amount & "&#039Const : &#039" & GoldInHand & "&#039"<BR>Else<BR> Session("AreaDescription") = "You don&#039t have that much money!" <BR>End If<BR><BR>Basically its a little game I&#039m working on, this bit is for the bank,players can put money in the bank but that can only put in up the amountthat they have on them. The problem comes from the second line in thecode. I&#039ve pasted here as it should be, but this does not work, leaving itt his way seems to alway make it skip down to the "you don&#039t have that muchmoney!" line. I&#039m using these numbers during testing : Player(GoldInHand)= 30000 and Amount = 100 so it should work buy does not. It does work if Ireplace the less than with a greater than which is really confusing and allows me to enter say 100,000 and it will except it. I&#039m really not surewhats going on and I&#039ve wasted hours trying to work it out.<BR><BR>Thanks<BR><BR>Anna K.

  2. #2
    Karl Guest

    Default RE: Greater than/lesser than mixup!

    Your code is fine...your less than sign is fine. So if you are evaluating an expression correctly, but are getting unexpected results, the error is being caused not by the evaluation, but by the values being evaluated.<BR><BR>So you think Player(GoldInHand) = 30000 and that Amount = 100, but they aren&#039t. Response.write their value before the if statement, make sure they are what you think they are. Make sure they are both digits. Test one independantly from the other<BR>(use 1 variable with one literal, and then the other variable with a literal). Add response.write&#039s...lot&#039s of them.<BR><BR>There are a lot of debugging techniques to be used. ASP&#039s lack of debugger is a serious problem. Nevertheless your problem should be easily fixable.<BR><BR>--<BR>Karl

Posting Permissions

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