help...about visual basic?

2008-01-14 12:47 pm
what's the code for dividing operator????

is'nt it just
text3.text = val(text1.text) / val(text2.text)
but why can't divide zero???
help plz

回答 (2)

2008-01-14 1:14 pm
✔ 最佳答案
The forward slash symbol is the divider operator | Correct

However, you cannot divide by Zero because the result of a division by zero is undefined in maths, and thus any attempt at a definition leads to a contradiction.

If you think about it, how do we define division?
   The ratio r of two numbers a and b:

Mathematically this is represented by:
   r = a/b

That would mean that a = r * B
   But what hapens if b = 0?
A contradiction occurs! If a <>0 then b cannot equal 0 can it

So I can see you thinking, ahh but what if a = 0?
   Well it is true that 0 = r * 0

Thus technically one could have 0/0 couldn't they?
   As it happens this causes a contradiction in math too. If you take the example 0/0, and call the result z then if it made sense, z would have to satisfy the following equation:

   z * 0=0

This is the contradiction: Any number divided by itself should equal ONE. However in this equation Z could be equal to any numerical value you can think of, thus if you alter the equation to z = 0/0 you can see there is no reason at all to assume z = 1

And these contradicions are why you cannot divide by zero on a computer or any other way.

Thus, you will need to create a conditon in your code above to ensure val(text2.text) never equals ZERO.
2016-05-25 1:30 pm
Visual basic is a great first language because it is very forgiving as far as programming languages go. In about an hour you can be up and creating simple calculation programs using VB. There are many great tutorials on the web that can help you get started. Just make sure you know which version of VB you are using. The older VB6 is much simpler than the newer VB.NET 2005. There really arent any languages to learn before VB because it is so simple. However, it can be a very powerful language. Good luck.


收錄日期: 2021-05-01 00:52:29
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20080114044742AAm2WuX

檢視 Wayback Machine 備份