0
votes

So, I am trying to learn vbscript and I bumped into a problem: type mismatch. I am unexperienced in vbs so I don't know where the mistake is. I am writing a program which asks for the sides of a right triangle and the angles, then the program gives me all of its data. So I need a code to get the angles by trigonometric functions(sin*α*=a/c and you know the "a" and the "c"). This is a part of the whole program (where the inverse trigonometric function is).Type in 0.8!(a=4,b=3,c=5):

u1 = "Type the quotient of a and c!"
f = "Math"
e =Inputbox(u1, f)
c = Sqr(-e^e+1)
a = Atn(e/c)
u = "α=" & a & vbCrLf
k = 0+64
msgbox u, k, f

If something is unclear please warn me. English isn't my native language so I don't know well the expressions of math. Best regards Matthew Szertel

1

1 Answers

0
votes

VBScript won't cope with the expression -e^e+1, unless e is an integer. It won't give you the exponent of a negative non-integer. But given that the exponent of a negative number is its absolute value (i.e. positive) maybe you can just do Sqr(e^e+1)? I tested this and it worked for me, though I did not verify the mathematical accuracy.

See: MSDN. This states that:

"Number can be negative only if exponent is an integer value."

I am not against VBScript per se, but it does not seem highly suitable for mathematical work.

Update: Re-reading your post I suspect you are typing " 0.8!" with an exclamation mark into the input box. If that is the case then you will indeed get a Type Mismatch, since a number with an exclamation mark will just be treated as a string, i.e. text, and cannot be used in any mathematical operation.