Results 1 to 4 of 4

Thread: mathematical operations on strings

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    2

    Cool 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

  2. #2
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    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]

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    2

    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

  4. #4
    PowerPoster Pasvorto's Avatar
    Join Date
    Oct 2002
    Location
    Minnesota, USA
    Posts
    2,951

    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
  •  



Click Here to Expand Forum to Full Width