|
-
Oct 31st, 2003, 05:00 PM
#1
Thread Starter
Member
TypeWriter Effect (code included in post)
its pretty simple and staight forward so here it is:
VB Code:
Private Declare Function GetTickCount Lib "kernel32" () As Long
Public Sub TypeWriter(txtt As TextBox, time As Single, text As String)
'^^^ for time you put the amount of seconds you want it to wait
Dim progress As Integer
Dim lastc As Long
progress = 1
lastc = GetTickCount
time = time * 1000
Do While progress <> (Len(text) + 1)
If GetTickCount - lastc > time Then
txtt.text = txtt.text + Mid(text, progress, 1)
txtt.Refresh
progress = progress + 1
lastc = GetTickCount
End If
DoEvents
Loop
End Sub
Private Sub Form_Load()
Me.Show
TypeWriter Text1, 0.5, "Welcome"
End Sub
a 17 year old kid who has nothing better to do !
and i never said i was right !!!
-
Nov 1st, 2003, 07:58 AM
#2
Supreme User
Nice one, i tried putting it into a label, but that wont display it properly. (even with a timer, and refresh). Is there anyway of putting it into a label?
Suppose i could just make the text box flat, and set focus to another control (to hide the | cursor position)
-
Nov 1st, 2003, 09:04 AM
#3
Thread Starter
Member
for a label change the declaration to:
VB Code:
Public Sub TypeWriter(txtt As Label, time As Single, text As String)
''^^^ make it a label instead of a textbox
and then change the .text property to caption:
VB Code:
txtt.Caption = txtt.Caption & Mid(text,progress,1)
a 17 year old kid who has nothing better to do !
and i never said i was right !!!
-
Nov 1st, 2003, 09:06 AM
#4
Supreme User
Yeah, im not daft - tried that. But it aint going to animate (or add text) to the label cos it needs updating. Im not bothered though
-
Nov 1st, 2003, 09:09 AM
#5
Thread Starter
Member
This code works fine for me with a label:
VB Code:
Private Declare Function GetTickCount Lib "kernel32" () As Long
Public Sub TypeWriter(txtt As Label, time As Single, text As String)
'^^^ for time you put the amount of seconds you want it to wait
Dim progress As Integer
Dim lastc As Long
progress = 1
lastc = GetTickCount
time = time * 1000
Do While progress <> (Len(text) + 1)
If GetTickCount - lastc > time Then
txtt.Caption = txtt.Caption + Mid(text, progress, 1)
txtt.Refresh
progress = progress + 1
lastc = GetTickCount
End If
DoEvents
Loop
End Sub
Private Sub Form_Load()
Me.Show
TypeWriter Label1, 0.5, "Welcome"
End Sub
a 17 year old kid who has nothing better to do !
and i never said i was right !!!
-
Nov 1st, 2003, 09:11 AM
#6
Supreme User
Just realized , i was using a third party ocx label, which doesnt use .Caption but .Label as the text appearance. Thanks again!
-
Nov 1st, 2003, 09:44 AM
#7
Supreme User
Im making a app called "VB Code Library" which has loads of API,codes,links,tips,snippets & tutorials. I was wondering if i could include your code into the library?
-
Nov 1st, 2003, 10:00 AM
#8
-
Nov 1st, 2003, 10:45 AM
#9
Thread Starter
Member
sure you can use this code or modify anyway you want. have fun with it !
a 17 year old kid who has nothing better to do !
and i never said i was right !!!
-
Nov 1st, 2003, 10:47 AM
#10
Supreme User
Ok thanks dude
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
|