Private
Sub
Form_KeyDown(KeyCode
As
Integer,
Shift
As
Integer)
If
KeyCode
=
13
Then
MsgBox
"你按下了Enter键!",,"Tips"
'这里的MsgBox可以更改为触发事件坦源
End
If
End
Sub
如果是输入完ComboBox之后按Enter触发事件,那么代码为:
Private
Sub
Combo1_KeyDown(KeyCode
As
Integer,
Shift
As
Integer)
If
KeyCode
=
13
Then
MsgBox
"你按下了Enter键!",,"Tips"
'这里的MsgBox可以更改为触发事件
End
If
End
Sub
你瞎信咐是要输入Enter后执行磨纯什么?网站浏览?还是其他?
Hi
此题侧重考察如何利用 Timer 控件来展示 ProgressBar 控件的动画过程。
下面给出必要步骤及参考代码。
窗基庆体中各控件命名如下:
txtSrc (TextBox Text1)
lblProgress (Label 进度:)
lblCurCopy (Label 当前复制:)
tmrCopy (Timer1)
cmdCopy (CommandButton 复制)
参考代码 (Form1):
Option ExplicitPrivate Type CopyProgress
Position As Long
Length As Long
CurText As String
SrcText As String
End Type
Dim udtCP As CopyProgress
Private Sub cmdCopy_Click()
With udtCP
.Position = 1
.SrcText 哗锋返= txtSrc.Text
.Length = Len(.SrcText)
.CurText = Mid$(.SrcText, .Position, 1)
lblProgress.Caption = CStr(.Position) & "/" & CStr(.Length)
End With
With pbCopy
.Min = CSng(udtCP.Position)
.Max = CSng(Len(udtCP.SrcText))
lblCurCopy.Caption = udtCP.CurText
End With
tmrCopy.Interval = 100
End Sub
Private Sub tmrCopy_Timer()
If pbCopy.Value = pbCopy.Max Then
tmrCopy.Interval = 0
MsgBox "OK", vbInformation, Me.Caption
lblProgress.Caption = vbNullString
lblCurCopy.Caption = vbNullString
pbCopy.Value = pbCopy.Min
乱饥 Exit Sub
End If
With udtCP
.Position = .Position + 1
.CurText = Mid$(.SrcText, .Position, 1)
lblProgress.Caption = CStr(.Position) & "/" & CStr(.Length)
lblCurCopy.Caption = .CurText
End With
pbCopy.Value = pbCopy.Value + 1
End Sub
动画效果:
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)