|
-
Jun 6th, 2001, 04:52 PM
#1
Thread Starter
Hyperactive Member
timer/counter help!
ok, i need a code that will add the number 1 every time the sub is called, so it will show 1,2,3,4,5,6,7 if it has been called 7 etc times. i want it to be in a timer so i know how many times a nother code has been called; i want the number to be showed in a caption( label)
Last edited by Cmdr0Sunburn; Jun 6th, 2001 at 04:59 PM.
I know a lot oF Vb, expert in C++, and i think in assembly.
MSVC++6.NET
vb6
masm
Windowz Xp
I find my self using this a lot in C++
__asm {
}
-
Jun 6th, 2001, 05:06 PM
#2
Lively Member
Can you just set a variable for each sub and create a procedure that passes gets the sub name and adds 1 to it (or just add 1 right there in each procedure) and then display that variable in the text box...
Sub cmdStart_Click
iCmdStartClick = iCmdStartClick+1
...
...
end sub
What did you want the timer to do?
-
Jun 6th, 2001, 05:08 PM
#3
Thread Starter
Hyperactive Member
im a newbie at vb i dont know much
I know a lot oF Vb, expert in C++, and i think in assembly.
MSVC++6.NET
vb6
masm
Windowz Xp
I find my self using this a lot in C++
__asm {
}
-
Jun 6th, 2001, 05:10 PM
#4
Somethin' like...
VB Code:
Static i As Integer
Private Sub MySub()
Timer1.Enabled = True
'rest of code
End Sub
Private Sub Command1_Click()
Call MySub
End Sub
Private Sub Command2_Click()
Msgbox "Times sub has been run: " & i
End Sub
Private Sub Timer1_Timer()
i = i + 1
Timer1.Enabled = False
End Sub
..Although, you could do this without a Timer.
-
Jun 6th, 2001, 05:11 PM
#5
2 ways: USe a Static variable, or declare it at module level
Example 1:
VB Code:
Sub MySub
Static i As Integer
i = i + 1
Label1 = i
End Sub
Example 2:
VB Code:
Private i As Integer 'In General section
Sub MySub
i = i + 1
Label1 = i
End Sub
-
Jun 6th, 2001, 05:11 PM
#6
Lively Member
oh, sorry! you want it to show all the numbers.
OK, how about this...
Dim sTimes as string
dim iNum as integer
Sub cmdStart_Click
setNum(getNum+1)
sCmdStartClick = sCmdStartClick & getNum & ","
...
...
end sub
Sub SetNum(iInt as integer)
iNum = iInt
end sub
Function getNum
getNum = iNum
end Function
-
Jun 6th, 2001, 05:24 PM
#7
Thread Starter
Hyperactive Member
I know a lot oF Vb, expert in C++, and i think in assembly.
MSVC++6.NET
vb6
masm
Windowz Xp
I find my self using this a lot in C++
__asm {
}
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
|