Visual Basic - The Best Typewriting Code!
Code:
'Virtually the best typewriting code available.
'All others i have seen are much longer.
'I am now currently working on a "wait" function
'so there is no need for a timer.
Private Sub Timer1_Timer()
Typewrite "Testing"
End Sub
Private Function Typewrite(Word As String)
'Function Simply Processes Effect Of A Typewriter.
Static NextChar As Integer 'Move onto the next character.
Dim Length As Integer 'Used for increasing length.
Dim Display As String 'Letters to display.
NextChar = NextChar + 1 'Move onto the next letter.
Length = Length + 1 'Increase the length of the word.
Display = Mid$(Word, NextChar, Length) 'What to display.
Label1.Caption = Label1.Caption & Display 'Display!
End Function
If anyone has any ideas how to include a wait function then please offer me your opinions. :bigyello:
Re: Visual Basic - The Best Typewriting Code!
Quote:
Originally posted by vb Legend
Code:
'Virtually the best typewriting code available.
'All others i have seen are much longer.
'I am now currently working on a "wait" function
'so there is no need for a timer.
Public sub Typewrite(byval strWord As String, byval dteDelayFor as date)
'Function Simply Processes Effect Of A Typewriter.
Dim dteDisp as Date 'DateTime to disp after
Dim lngCtr as long
for lngCtr = 0 to len(strWord)
Label1.Caption = mid$(strWord,1,lngCtr)
dteDisp = now + dteDelay
do until now>dteDisp
' Delay around here
loop
next
End sub
This sort of works, but not brilliantly. Probably need the gettickcount api call to get a more accurate time.
To run :
TypeWrite "Testing",Cdate("0:0:01")
Vince