VB 自动加减怎么做,请高手指教!
vb有这样的一个界面,上面只有一个textbox和一个button,功能是,按一下Button,textbox中的数字他就自动减少1,一直到0为止,具体代码怎么写?请高手...
vb 有这样的一个界面,上面只有一个textbox和一个button,功能是,按一下Button,textbox中的数字他就自动减少1,一直到0为止,具体代码怎么写?请高手指教!!
展开
展开全部
Public Sub Command1_Click()
If Val(Text1.Text)<>0 Then
Text1.Text=Val(Text1.Text)-1
Else
MsgBox "已经为0"
End If
End Sub
你也许是
---------Module1-----------
Public Declare Function timeSetEvent Lib "winmm.dll" (ByVal uDelay As Long, ByVal uResolution As Long, ByVal lpFunction As Long, ByVal dwUser As Long, ByVal uFlags As Long) As Long
Public Declare Function timeKillEvent Lib "winmm.dll" (ByVal uID As Long) As Long
Public Id As Long
Public Sub TimeProc(ByVal uID As Long, ByVal uMsg As Long, ByVal dwUser As Long, ByVal dw1 As Long, ByVal dw2 As Long)
If Val(Form1.Text1.Text)<>0 Then
Form1.Text1.Text=Val(Form1.Text1.Text)-1
Else
timeKillEvent Id
End If
End Sub
----------------Form1--------------
Private Sub Command1_Click()
Id=timeSetEvent(1000,10,Addressof TimeProc,1,1)
End Sub
If Val(Text1.Text)<>0 Then
Text1.Text=Val(Text1.Text)-1
Else
MsgBox "已经为0"
End If
End Sub
你也许是
---------Module1-----------
Public Declare Function timeSetEvent Lib "winmm.dll" (ByVal uDelay As Long, ByVal uResolution As Long, ByVal lpFunction As Long, ByVal dwUser As Long, ByVal uFlags As Long) As Long
Public Declare Function timeKillEvent Lib "winmm.dll" (ByVal uID As Long) As Long
Public Id As Long
Public Sub TimeProc(ByVal uID As Long, ByVal uMsg As Long, ByVal dwUser As Long, ByVal dw1 As Long, ByVal dw2 As Long)
If Val(Form1.Text1.Text)<>0 Then
Form1.Text1.Text=Val(Form1.Text1.Text)-1
Else
timeKillEvent Id
End If
End Sub
----------------Form1--------------
Private Sub Command1_Click()
Id=timeSetEvent(1000,10,Addressof TimeProc,1,1)
End Sub
展开全部
sub click()
i=val(textbox.text)
if i>1 then
i=i-1
end
textbox.text=format(i,"0")
end sub
i=val(textbox.text)
if i>1 then
i=i-1
end
textbox.text=format(i,"0")
end sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
private sub command1_click()
if val(text1.text)>0 then
text1.text=val(text1.text)-1
end if
end sub
if val(text1.text)>0 then
text1.text=val(text1.text)-1
end if
end sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
sub click()
i=val(textbox.text)
i=i-1
textbox.text=format(i,"0")
end sub
i=val(textbox.text)
i=i-1
textbox.text=format(i,"0")
end sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
dim i as integer
private sub command1_click()
i=text1
i=i-1
text1=i
if i=0 then
msgbox "零,自动停止"
exit sub
end if
end sub
private sub command1_click()
i=text1
i=i-1
text1=i
if i=0 then
msgbox "零,自动停止"
exit sub
end if
end sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询