點擊啟動按鈕時文本框內(nèi)容自動顯示100次,到了100次立即清零重新開始,如果選中復(fù)選框按鈕,則進(jìn)度條進(jìn)度會跟隨文本框的內(nèi)容變。
點擊重做按鈕時,所有的都停止。代碼如下:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox1.MaxLength = 100 '文本框最大長度為100
TextBox1.ReadOnly = True '文本框在運行時只讀,不可寫入
TextBox1.Multiline = True '文本框內(nèi)容可在多行顯示
Timer1.Interval = 10 '間隔10ms顯示“8”
' Me.AcceptButton = Button1 '按鍵盤上回車鍵同點擊Button1 按鈕有相同的效果
' Me.CancelButton = Button2 ‘按鍵盤上esc鍵同點擊Button2 按鈕效果相同
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Button1.Enabled = False
Timer1.Enabled = True
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Timer1.Enabled = False
Button1.Enabled = True
TextBox1.Text = ""
Label1.Text = "當(dāng)期字符數(shù)=" & TextBox1.Text
CheckBox1.Checked = False
ProgressBar1.Value = 0
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
TextBox1.Text = TextBox1.Text & "8"
Label1.Text = "當(dāng)前字符數(shù)=" & TextBox1.TextLength '標(biāo)簽內(nèi)容動態(tài)顯示文本框長度
If TextBox1.TextLength = TextBox1.MaxLength Then '如果文本框長度等于最大長度則文本框清零重新計數(shù)
TextBox1.Text = ""
End If
If CheckBox1.Checked = True Then
ProgressBar1.Value = TextBox1.TextLength '如果選中了復(fù)選框,進(jìn)度條跟隨文本框長度一起變化
End If
End Sub
End Class
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點擊舉報。