Tải bản đầy đủ (.docx) (2 trang)

Các chiêu thức trong lập trình Hiện một câu bằng cách lần lượt hiện từng chữhome

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (61.92 KB, 2 trang )

Hiện một câu bằng cách lần lượt hiện từng chữ home
Xuất xứ : www.pscode.com
Binh khí sử dụng : Một Module , ba CommandButton lần lượt có các tên cmdStart, cmdClear, cmdExit,
thêm hai cái đồng hồ tên là Timer1 (Interval =50) và Timer2(Interval =5) cả hai cái đồng hồ đều phải
Enabled= False cuối cùng là một label tên là lblText
Đoạn mã :
Module :
Public ASCC(5) As String
Public Letters() As String ' Chuỗi ký tự
Public TXT As String
Public CurLetter As Integer
Public TEXTT As String
Public r As Integer
Form :
Private Sub cmdClear_Click()
lblText.Caption = ""
End Sub
Private Sub cmdExit_Click()
End
End Sub
Private Sub cmdStart_Click()
TXT = InputBox("Enter Text") ' Nhập ký tự
ReDim Preserve Letters(0)
ReDim Preserve Letters(Len(TXT))
lblText = ""
CurLetter = 0
For l = 1 To Len(TXT)
Letters(l) = Mid(TXT, l, 1)
Next
Timer2.Enabled = True
End Sub


Private Sub Timer1_Timer()
r = r + 1
lblText.Caption = TEXTT
lblText.Caption = lblText.Caption & "_"
If r = 6 Then
r = 0
If 65 < Asc(Letters(CurLetter)) < 90 Then
lblText.Caption = TEXTT
lblText.Caption = lblText.Caption & Letters(CurLetter)
TEXTT = lblText
Timer2.Enabled = True
Timer1.Enabled = False
Else
lblText.Caption = TEXTT
lblText.Caption = lblText.Caption & Chr$(Asc(Letters(CurLetter)) - 32)
TEXTT = lblText
Timer2.Enabled = True
Timer1.Enabled = False
End If

End If

End Sub
Private Sub Timer2_Timer()
CurLetter = CurLetter + 1
If CurLetter > Len(TXT) Then
GoTo HERE:
End If
TEXTT = lblText
Timer1.Enabled = True

Timer2.Enabled = False
HERE:
Timer2.Enabled = False
End Sub

×