|
-
Sep 5th, 2005, 10:38 AM
#1
Thread Starter
Addicted Member
Re: Loops making me loopy!
i'm getting wierd results doing it like this. for starters it automatically sets the total as 500. if i put in a number 5 it sets the total as 500, if i put in 6 then it sets the total as 504, putting in 3 sets its as 502. very strange.
-
Sep 5th, 2005, 10:43 AM
#2
Re: Loops making me loopy!
If you put in the DEBUG.PRINT statements you can "step" through the code one line at a time (with F8) and watch exactly what is going on.
-
Sep 5th, 2005, 10:43 AM
#3
Member
Re: Loops making me loopy!
That's because 6 and 3 don't go evenly into 500
EDIT: I found another problem. At the bottom of your code:
This
txtTotal.Text = Total
Should be this
Total = txtTotal.Text
Last edited by millertime; Sep 5th, 2005 at 10:46 AM.
-
Sep 5th, 2005, 10:44 AM
#4
Thread Starter
Addicted Member
Re: Loops making me loopy!
i know what its doing now. its just looping any number i put in until the total is over 500 when it stops.
well i'm a bit confused about the question now. i can't see how i can do this question using loops.
-
Sep 5th, 2005, 10:55 AM
#5
Re: Loops making me loopy!
 Originally Posted by oldmcgroin
i'm getting wierd results doing it like this. for starters it automatically sets the total as 500. if i put in a number 5 it sets the total as 500, if i put in 6 then it sets the total as 504, putting in 3 sets its as 502. very strange.
you are doing :
Code:
Static Total As Integer
Total = 0
This way Total will never be increasing.
This one should work:
VB Code:
Option Explicit
Private Sub cmdOk_Click()
Static Total As Integer
If Total >= 500 Then
MsgBox "Total Capacity Reached"
Exit Sub
ElseIf Not IsNumeric(txtNumber.Text) Then
MsgBox "Not a number"
Exit Sub
End If
Total = Total + txtNumber.Text
txtTotal.Text = Total
End Sub
Pradeep
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
|