|
-
May 28th, 2000, 01:42 AM
#1
Thread Starter
New Member
This is gonna stupid but is there and Increment function in VB? that will inc any integer var by another integer or just 1.
thanx
-
May 28th, 2000, 01:48 AM
#2
Guru
Well, you can always do this:
X = X + 1
This will increment the variable X by one.
X = X + Y
This will increment the variable X by Y.
You can always use other mathematical expressions:
X = X - 1
X = X / 2
X = X * Y + 5
X = Cos(X * Sin(5 ^ Y))
-
May 28th, 2000, 02:51 AM
#3
Fanatic Member
Don't know of any functions for that. Like ++ in C. But we are currently working on a new reference library DLL, and inc happens to be one of the functions we have built. If there are any others you would like to see let us know.
[email protected] or [email protected].
-
May 28th, 2000, 03:06 AM
#4
I have known about that incrementing for a long time...
I always try to use it, like in a timer, and it never works....
I set the timer interval to 1000, I enable the timer
and put this code into the timer1_timer module
Code:
Private Sub Timer1_Timer()
i = i + 1
Text1 = i
End Sub
this doesnt work... text1 = 1 then it doesnt do anything else
-
May 28th, 2000, 03:52 AM
#5
Guru
If you really want to use a function:
Sub Inc(ByRef X, Optional ByVal NumberToIncreaseBy = 1)
X = X + NumberToIncreaseBy
End Sub
Same with Dec except a minus instead of a plus.
Regarding the timer...
Whenever the timer routine is called, the I variable is recreated and reset with zero. To make it static (not reset), you have to tell it to be static, like this:
Code:
Private Sub Timer1_Timer()
Static I As Integer
I = I + 1
Text1 = I
End Sub
-
May 28th, 2000, 04:28 AM
#6
Or you could decalre a variable as Public or Global in a module, then in a Timer, put the following code.
Code:
Private Sub Timer1_Timer()
' Add 1 to the variable
MyVar = MyVar + 1
Text1 = MyVar
End Sub
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
|