DanceCaption




Option Explicit
Public a, b, txt1, singlebit, mytext, newtext, titletext, dance, state
Private Sub Form_Load()
'set the timer interval, change this to make it go faster

Form1.Timer1.Interval = 300
'put text in title

txt1 = "can you Do the can-can?"
dance = Proper(txt1)
state = 1
End Sub

Private Function Proper(textTochange As Variant)
'this demonstrates how to make a function

'the function reads txt1 and change all the caracters into CAPS

'read the text one character at a time

For a = 1 To Len(textTochange)
singlebit = Mid(textTochange, a, 1)
'demonstrates the Case function

Select Case singlebit
Case "a"
newtext = newtext & "A"
Case "b"
newtext = newtext & "B"
Case "c"
newtext = newtext & "C"
Case "d"
newtext = newtext & "D"
Case "e"
newtext = newtext & "E"
Case "f"
newtext = newtext & "F"
Case "g"
newtext = newtext & "G"
Case "h"
newtext = newtext & "H"
Case "i"
newtext = newtext & "I"
Case "j"
newtext = newtext & "J"
Case "k"
newtext = newtext & "K"
Case "l"
newtext = newtext & "L"
Case "m"
newtext = newtext & "M"
Case "n"
newtext = newtext & "N"
Case "o"
newtext = newtext & "O"
Case "p"
newtext = newtext & "P"
Case "q"
newtext = newtext & "Q"
Case "r"
newtext = newtext & "R"
Case "s"
newtext = newtext & "S"
Case "t"
newtext = newtext & "T"
Case "u"
newtext = newtext & "U"
Case "v"
newtext = newtext & "V"
Case "w"
newtext = newtext & "W"
Case "x"
newtext = newtext & "X"
Case "y"
newtext = newtext & "Y"
Case "z"
newtext = newtext & "Z"
'case else will ignore the carater if it is not in lowercase

'and use it as is

Case Else
newtext = newtext & singlebit
End Select
Next a
'set the return for function Proper

Proper = newtext
End Function

Private Sub Timer1_Timer()
'clear the title text

titletext = ""
Select Case state
'alternate the caps and the lowercase letters

Case 1
For b = 1 To Len(dance) Step 2
titletext = titletext & Mid(dance, b, 1)
titletext = titletext & Mid(txt1, b + 1, 1)
Next b
state = 2
'jump to skip case 2

Goto ending
'ulternate the caps and lowercase letters but in reverse

Case 2
For b = 1 To Len(dance) Step 2
titletext = titletext & Mid(txt1, b, 1)
titletext = titletext & Mid(dance, b + 1, 1)
Next b
state = 1
End Select
ending:
Form1.Caption = titletext
End Sub

Creare un nuovo progetto ed inserite un controllo Timer











( dancecaption.html )- by Paolo Puglisi - Modifica del 17/12/2023