怎么做计算? [英] how to do calculations?

查看:118
本文介绍了怎么做计算?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在vb.net中进行计算吗?

我有一个需要在按钮中使用计算的项目,例如,单击按钮时,每次它将减去-1.它将减去数据库中的点.

确切地说,数据库中有一个名为table1的表.并且有列调用点.

我正在考虑以这种方式进行操作,即每次单击按钮时,该特定列的点都将减去.

May I know how to do calculation in vb.net?

I have a project which I need to use calculation in the button, when clicked the button, it will minus 1 each time for example. And it will minus off the points in the database.

To be exact, there is a table in database called table1. and there is column call points.

I am thinking of doing it in the way that everytime I click the button, the points of that particular column will be minus off.

推荐答案

每次按下按钮时项目的值,您将在按钮事件内执行以下操作:

To take one off of the value of an item each time the button is pressed, you would do something like this inside the button event:

value = value - 1



在C#中,可以使用-=运算符从一个值中取一个,但是我不相信VB.NET中有类似的运算符.

将数据库添加到组合中将使此过程变得更加复杂.您需要确定每次按下按钮时是否要写入数据库.如果是这样,您将需要编写一个查询,将新值添加到旧值的位置.它很可能是sql UPDATE语句.像这样的东西:



In C#, you can use the -= operator to take one off of a value, but I don''t believe there is a similar operator in VB.NET.

Adding a database to the mix will make this more complicated. You need to figure out if you want to write to the database each time the button is pressed. If so, you will need to write a query that adds the new value into the spot of the old value. It will most likely be a sql UPDATE statement. Something like this:

UPDATE yourTable
SET Points = <newvalue>
WHERE id = <the id of the record you are going to update>


如果您刚刚开始使用VB.NET,我建议您在这一点上退后一步,并浏览一些有关数据访问的基本教程.通读一些并继续.这将使您更好地掌握如何解决此类问题.在没有对语言有很好的基础了解的情况下尝试解决特定的问题,即使是简单的任务也非常困难.


If you are just getting started in VB.NET, I would recommend you take a step back at this point and look through some basic tutorials on data access. Read through a few and follow along. That will give you a better grasp of how to attack this type of problem. Trying to solve specific problems without a good foundational understanding of the language makes even simple tasks very difficult.


这篇关于怎么做计算?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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