Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A lot of time questions 1

Status
Not open for further replies.

Ablecken

Programmer
Jun 5, 2001
130
US
Okay, I have a lot of questions.
First:
If I have a user inputing numbers and I want the numbers to be only two digits long.... how? this is for seconds. The number can not be over 60. if they put 65 i want it so that it will be 1 min 5 sec. how do i know if they put 1 number or 5 numbers in the text box?? if its only one number how can i add a zero in front?


Two:
How would i countdown from sixty using real seconds. i know that i have to use a timer...

Thanx a lot guys for helping a newbie

this forum rocks :)
 
Another

What i want to do is do a countdown timer with the numbers users input. what would be a good way to do this. like if it has 1 min 23 sec to go countdown the 23 sec. put min to 0 then count down 60 sec???

Thanx again
 
Okay I will do my best to help you with your questions in order

Number one :Only numbes in a text box.

Paste this code


'vb2themax
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

' Force a TextBox control to accept only numeric digits
' Cancel the effect by passing Force = False
'
' Note that it only accepts positive integer values

Sub ForceTextBoxNumeric(TextBox As TextBox, Optional Force As Boolean = True)
Dim style As Long
Const GWL_STYLE = (-16)
Const ES_NUMBER = &H2000

' get current style
style = GetWindowLong(TextBox.hWnd, GWL_STYLE)
If Force Then
style = style Or ES_NUMBER
Else
style = style And Not ES_NUMBER
End If
' enforce new style
SetWindowLong TextBox.hWnd, GWL_STYLE, style
End Sub



then in form load use forcetextboxnumber then the name.

Okay Number ??: Counting down
this will count down from the number in the text box

here are the property of the timer at start

.enabled = fasle
.interval = 1000

Okay now for the code in the timer.



Do Until Count = text1.text

Count = Count + 1
Loop




to activate that u must activate is enabled = true.

If you want to restrict the amount of numbers in th text box then use this in the text change event


if text1.text > 100 then
text1.text = 99
End FI


That there will stop them from going over 99.

I'm sorry if i missed somethign wasn't clear or any of sort of mistake but it is late.

Cheers Brad,
Free mp3 player,games and more.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top