解决一个VB的小问题

来源:百度知道 编辑:UC知道 时间:2024/06/14 06:12:04
dim l as integer
l = InputBox("请输入长度", "长度窗口")
以上式中,我每输入一次值,在inputbox框中都自动计算出这次输入的与上次输入的差值。比方说我第一次输入3,l=3,第二次输入8,l=5,第三次输入10,l=2

Private Sub Form_Load()
Do
a = b
b = InputBox("请输入长度", "长度窗口", "0")
If b = vbcancle Or b = "" Then
MsgBox "没输入数字,程序结束!"

Exit Do
End If

MsgBox ("差值为:" & b - a)

Loop
End
End Sub

-------------
复制所有代码,运行看看是不是你所想要的效果?

貌似可以l=InputBox("请输入长度", "长度窗口") -l

dim oldnum as integer,newnum as integer

private sub Command1_Click()
oldnum=newnum
newnum = InputBox("请输入长度", "长度窗口")
print newnum-oldnum
end if

dim I as integer

provate Command1_Click()
I = InputBox("请输入长度", "长度窗口") -I
print I
end sub

Private Sub Form_Load()
form1.autoredrew=true
I=0
End Sub

是不是这样?