Results 1 to 3 of 3

Thread: Greater> less than stuff

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Posts
    18

    Post

    My program needs to charge $0.30 for 0-499 copies, $0.28 for 500-749 copies, $0.27 for 750-999 copies, $0.25 for 1000 or more copies
    But it reads $0.28 for everything 500 and over. The <> thing confuse me can anyone help me out;(

    Private Sub cmdcalculate_Click()
    Dim intcopy As Integer
    Dim curtotal As Currency
    Dim curpercopy As Currency
    intcopy = txtcopy.Text
    If intcopy <= 499 Then
    intpercopy = 0.3
    ElseIf intcopy >= 500 < 750 Then
    intpercopy = 0.28
    ElseIf intcopy >= 750 < 1000 Then
    intpercopy = 0.27
    ElseIf intcopy >= 1000 Then
    intpercopy = 0.25
    End If
    lblpercopy.Caption = intpercopy
    lbltotalprice.Caption = intpercopy * intcopy
    End Sub

  2. #2
    Addicted Member
    Join Date
    Jan 2000
    Location
    Sydney, Australia
    Posts
    196

    Post

    The problem is in your syntax

    you need:

    ElseIf intcopy >= 500 And intcopy < 750 Then

    etc etc. What was happening before (i think) is that it is first evaluating "intcopy >= 500" which it was and it returns "True". Now, internally True has a value of -1. So now the compare is -1 < 750 (ie, it uses the result of "intcopy >= 500" and uses it in the "< 750" compare. obviously, -1 is less than 750 so the whole condition becomes true and that is why you always get 0.28

    hope this explains it,.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2000
    Posts
    18

    Post

    ok fixed my problem thanks

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