|
-
Feb 21st, 2000, 09:42 AM
#1
Thread Starter
Junior Member
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
-
Feb 21st, 2000, 09:55 AM
#2
Addicted Member
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,.
-
Feb 21st, 2000, 10:28 AM
#3
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|