Senin, 18 September 2023

Scroll Text in InputBox VB6

Double klik tombol Start
ketik kode di bawah ini :

Option Explicit
Private Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Private GInt, PreLen, SufLen As Integer
Const MyMessage As String = "Hello World   "

Private Sub Command1_Click()
' Start the timer
' Parameters - handle, ID, MilSecs, address of handler
SetTimer Me.hwnd, 50, 200, AddressOf TimerHandler
End Sub

Private Sub Command2_Click()
' Stop the timer
' Parameters - handle, ID
KillTimer Me.hwnd, 50
End Sub

Public Sub MoveTicker()
If GInt = Len(MyMessage) Then GInt = 1
PreLen = Len(MyMessage) - GInt
SufLen = Len(MyMessage) - PreLen
Text1.Text = Mid(MyMessage, GInt, PreLen) & Left(MyMessage, SufLen)
GInt = GInt + 1
End Sub

Private Sub Form_Load()
GInt = 1
End Sub


buat file modul baru
Modul1.bas
ketik kode di bawah ini
Public Sub TimerHandler(ByVal hwnd As Long, ByVal uMsg As Integer, ByVal idEvent As Integer, ByVal dwTime As Long)
' This is our time callback event handler
Form1.MoveTicker
End Sub

struktur folder


 

Tidak ada komentar: