home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / common1r / form1.frm (.txt) next >
Encoding:
Visual Basic Form  |  1999-08-26  |  3.5 KB  |  113 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "DasherSW's Moving Caption Sample..."
  4.    ClientHeight    =   525
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4875
  8.    LinkTopic       =   "Form1"
  9.    MaxButton       =   0   'False
  10.    Moveable        =   0   'False
  11.    ScaleHeight     =   525
  12.    ScaleWidth      =   4875
  13.    StartUpPosition =   2  'CenterScreen
  14.    Begin VB.Timer Timer1 
  15.       Left            =   0
  16.       Top             =   0
  17.    End
  18.    Begin VB.CommandButton Start 
  19.       Caption         =   "Start"
  20.       Height          =   495
  21.       Left            =   420
  22.       TabIndex        =   0
  23.       Top             =   0
  24.       Width           =   1215
  25.    End
  26.    Begin VB.Label Label1 
  27.       BackStyle       =   0  'Transparent
  28.       Caption         =   "You can place Start_Click in Form_Load so that it starts to move just after form is loaded."
  29.       Height          =   435
  30.       Left            =   1680
  31.       TabIndex        =   1
  32.       Top             =   60
  33.       Width           =   3135
  34.    End
  35. Attribute VB_Name = "Form1"
  36. Attribute VB_GlobalNameSpace = False
  37. Attribute VB_Creatable = False
  38. Attribute VB_PredeclaredId = True
  39. Attribute VB_Exposed = False
  40. Rem Code by DasherSW. 'Hope i' will teach u some.
  41. Rem know this variables declared at first will always work
  42. Rem faster than getting the needed value at run time.
  43. Rem Const values cannot change.
  44. Rem declarations
  45. Rem the amount of spaces the caption will move left
  46. Const CapSpace As Integer = 10
  47. Rem the interval of the timer
  48. Const TimerInt As Integer = 50
  49. Rem if its in phase of moving right
  50. Dim MovRight As Boolean
  51. Rem if its in phase of disappearing into right
  52. Dim Disapear As Boolean
  53. Rem if its in phase of reappearing from left
  54. Dim StartAga As Boolean
  55. Rem the length of caption
  56. Dim CaptiLen As Integer
  57. Rem default caption.
  58. Dim DefCapti As String
  59. Private Sub Form_Load()
  60. CaptiLen = Len(Form1.Caption)
  61. DefCapti = Form1.Caption
  62. End Sub
  63. Private Sub Start_Click()
  64. MovRight = True
  65. Disapear = False
  66. StartAga = False
  67. Timer1.Interval = TimerInt
  68. End Sub
  69. Private Sub Timer1_Timer()
  70. Rem make i a loop variable
  71. Static i As Integer
  72. Rem if i is equal to capspace then start disapear phase
  73. If i = CapSpace Then
  74. i = 0
  75. MovRight = False
  76. Disapear = True
  77. End If
  78. Rem if still in movright phase and i < capspace then
  79. If MovRight = True Then
  80. Form1.Caption = Space(1) & Form1.Caption
  81. Rem increase value of i one by one to make it equal to capspace
  82. i = i + 1
  83. End If
  84. Rem if disapear phase (if the caption must disapear through right now)
  85. If Disapear = True Then
  86. Rem give caption 2 spaces from left and take one letter from right
  87. Form1.Caption = Space(2) & Left(Form1.Caption, (Len(Form1.Caption) - 1))
  88. End If
  89. Rem if all of the visible (excluding spaces) caption has disappeared
  90. If Len(Form1.Caption) = CaptiLen + CaptiLen + CapSpace Then
  91. Disapear = False
  92. Rem start the StartAgain phase
  93. StartAga = True
  94. End If
  95. Rem if start again phase has started then
  96. If StartAga = True Then
  97. Static r
  98. Rem make form1 caption to get each letter from right of the DefCapti.
  99. Rem defcapti here helps us to reappear the true caption.
  100. Rem if you don't like to use this easier way, the defcapti,
  101. Rem you can count spaces and leave them off to take the cap.
  102. Form1.Caption = Right(DefCapti, r)
  103. r = r + 1
  104. End If
  105. Rem if form1 caption = the first caption then
  106. If Form1.Caption = DefCapti Then
  107. Rem r=0 so that the cap will not move forever in the 3rd loop.
  108. r = 0
  109. Rem start everything again....
  110. Start_Click
  111. End If
  112. End Sub
  113.