|
-
Jun 26th, 2007, 02:04 PM
#1
Thread Starter
New Member
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.
Last edited by gevs; Jun 26th, 2007 at 02:05 PM.
Reason: correction
-
Jun 26th, 2007, 02:28 PM
#2
PowerPoster
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)
===================================================
If your question has been answered, mark the thread as [RESOLVED]
-
Jun 26th, 2007, 02:32 PM
#3
Thread Starter
New Member
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
Last edited by gevs; Jun 26th, 2007 at 02:42 PM.
Reason: correction
-
Jun 26th, 2007, 02:46 PM
#4
PowerPoster
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.
===================================================
If your question has been answered, mark the thread as [RESOLVED]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|