|
-
Jun 3rd, 2001, 08:20 PM
#1
Thread Starter
Member
sounding like a newbie...
i know i sound like a complete newbie right now, but i've been wondering why this doesnt work for a while
it just basically adding 1 to a variable each time...but for some reason, it doesnt...
ive tried in a timer, loop, and for/next statement.
all i want to do is some like
Code:
Dim X As Integer
X = X + 1
and make it return a new number every second(or whatever the case is: timer, for/next, etc...)
So why doesnt this work?
im feeling pretty stupid right now, so thanks to anyone who can correct the stupid error im making. any posts are appreciated. thanks.
-
Jun 3rd, 2001, 08:57 PM
#2
Fanatic Member
You have to give it a value first. You can't just say:
Dim x
x = x + 1
because the computer won't know what the value of x is, and therefore can't add to it.
Alcohol & calculus don't mix.
Never drink & derive.
-
Jun 4th, 2001, 01:11 PM
#3
Fanatic Member
Try this...
choochoo, I would reccomend either of the following.
Using a timer...
Code:
Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Static x As Integer
x = x + 1
Debug.Print x
End Sub
Using a public variable...
Code:
Public x As Integer
Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
x = x + 1
Debug.Print x
End Sub
Hope this helps!
Digital-X-Treme
Contact me on MSN Messenger: [email protected]
[VBCODE]Debug.Print Round(((1097) - ((55 ^ 5 + 311 ^ 3 - 11 ^ 3) _
/ (68 ^ 5))) ^ (1 / 7), 13)[/VBCODE]
-
Jun 4th, 2001, 01:58 PM
#4
Thread Starter
Member
thanks for replying to my post.
wynd, i had tried setting its value before, that hadnt worked either :\
Digtal-X-Treme, yes that did help, thanks alot.
-
Jun 4th, 2001, 08:40 PM
#5
Dazed Member
// heres a simple loop that prints out the integer values 1 to 10
// in Java.
// just to show an example of what you are trying to acheive.
// in another language.
public class Test{
public static void main(String[] args){
int i = 0; // automatic variable
// ie.. local to the method block
while(i != 10){
i = i + 1;
System.out.println(" The value of i is: " + i);
}
}
}
you were doing the right thing i just think you were not doing the timer part properly. From what i remember of VB, variables are
automatically initialized. Good Luck!!!
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
|