如何在Do循环中使用InputBox [英] How to use a InputBox in a Do Loop

查看:134
本文介绍了如何在Do循环中使用InputBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用InputBox在Do Loop中计算数字?并且当没有更多要计算的数字时,总数应显示在标签中.

How do I use a InputBox to calculate numbers in a Do Loop? And when there are no more numbers to calculate, the total should be displayed in a label.

推荐答案

您为什么要?它不完全是用户友好的,对吗?

假设这是Winforms,而不是基于Web的(因为如果您基于Web,则您*确实*不想使用Inputbox):

创建一个新表单.
在表单上放置一个文本框,一个标签和两个按钮.
将一个按钮标记为完成",将另一个按钮标记为添加",
在表单代码中,添加一个名为总计"的类级别编号.在Load事件中将其设置为零.
在添加"按钮处理程序中,读取TextBox.Text值,将其转换为数字并将其添加到总计中.清除TextBox.Text并在标签中显示总计".
在完成"按钮处理程序中,关闭表单.
Why would you want to? It''s not exactly user friendly, is it?

Assuming this is winforms, rather than web based (because if you are web based, you *really* don''t want to use Inputbox):

Create a new form.
Place a text box, a label, and two buttons on the form.
Label one button "Done" and the other "Add",
In the form code, add a class level number called Total. Set it to zero in the form Load event.
In the "Add" button handler, read the TextBox.Text value, convert it to a number and add it to the Total. Clear the TextBox.Text and display the Total in the label.
In the "Done" button handler, close the form.


这篇关于如何在Do循环中使用InputBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆