mathematical operations on strings
I just inherited a program that does a bunch of mathematical operations on strings, ie, subtraction and multiplication. It appears that the complier converts the strings to single, does the operation, and converts it back. That is what I need but never used strings that way. I am nervous about this. What are the rules that the complier uses for these conditions? I don't get a type mismatch error even as the variables are declared as Strings and assigned to a mathematical operation.
Re: mathematical operations on strings
Do you mean something like:
dim string1 as string
dim num1 as integer
string = "2"
num1 = cint(string1)
num1 = num1 * 2
string1 = cstr(num1)
Re: mathematical operations on strings
That is what I would expect to see. However, the program does this
Dim stringnumber1, stringnumber2, stringnumber3 as String
stringnumber3 = stringnumber1 * stringnumber2
Re: mathematical operations on strings
I would think that you have stringnumber1 & stringnumber2 as variant data types and stringnumber3 as a string..
so the program will decide that number1 & number2 are numeric (based on their values) and convert the result to a string.