怎样循环???
For i = 1 To 100000
Me.lbl.Text = i + 1
Next
类似秒表一样的效果.
怎样实现 me.lbl.text 从1一直到10万(也就是数字会一直变且不会造成程序假死的..) --------------------编程问答-------------------- 用TIMER空件,响应TICK时间 --------------------编程问答--------------------
--------------------编程问答-------------------- 不是很明白楼主意思 --------------------编程问答--------------------
For i = 1 To 100000
Me.lbl.Text = i + 1
Application.DoEvents()
Next
'循环还在进行的时候我关闭窗体貌似没释放内存???
--------------------编程问答--------------------
'由此自定义 计时 - 线程开始
Dim Ts As New Threading.Thread(AddressOf Run)
Ts.IsBackground = False
Ts.Start()
Overloads Sub Update()
Try
for i = 0 to 10000
lblTime.Text = i+1
'退出事件 或者退出循环 否则页面关闭循环继续
Exit Sub
End If
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Sub Run()
Try
Do
Invoke(New MethodInvoker(AddressOf Update))
'暂停1秒
Thread.Sleep(1000)
Loop
Catch ex As Exception
End Try
End Sub
Overloads Sub Update()--------------------编程问答--------------------
Try
For i = 0 To 10000
Label2.Text = i + 1
Next
'退出事件 或者退出循环 否则页面关闭循环继续
Exit Sub
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Imports System.Windows.Forms--------------------编程问答-------------------- 循环体中加Application.DoEvents()
Class Form1
Inherits Form
Private Sub New()
Dim i As Integer = 0
Dim lbl As New Label()
lbl.Parent = Me
Dim tmr As New Timer()
tmr.Tick += Function() Do
lbl.Text = (System.Threading.Interlocked.Increment(i)).ToString()
End Function
tmr.Interval = 1000
tmr.Start()
End Sub
Private Shared Sub Main()
Application.Run(New Form1())
End Sub
End Class
--------------------编程问答--------------------
Imports System.Windows.Forms--------------------编程问答--------------------
Class Form1
Inherits Form
Private Sub New()
Dim i As Integer = 0
Dim lbl As New Label()
lbl.Parent = Me
Dim tmr As New Timer()
tmr.Tick += Function() Do
i = i + 1
lbl.Text = i.ToString()
If i = 100000 Then
tmr.[Stop]()
End If
End Function
tmr.Interval = 1000
tmr.Start()
End Sub
Private Shared Sub Main()
Application.Run(New Form1())
End Sub
End Class
--------------------编程问答--------------------
Dim i As Integer
For i = 1 To 100000
Me.Label1.Text = i + 1
My.Application.DoEvents()
Next
顶这个方法 --------------------编程问答-------------------- 用定时器最合理,加My.Application.DoEvents()最简单
补充:.NET技术 , VB.NET