Results 1 to 3 of 3

Thread: Question about using strings

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Posts
    18

    Question Question about using strings

    Hi

    I've got a simple calculator program which uses strings to contain the numbers entered as well as the answer. The problem I have is I can't perform any mathematical calulations with them. For example with the code I used to add the two numbers i.e. 2, 1 they donot add together they just combine so instead of getting the answer 3 I get 21. What am I doing wrong?

  2. #2
    Hyperactive Member Dodger's Avatar
    Join Date
    Mar 2001
    Posts
    433
    You must use:

    yourstring = 1 + 2

    Not:

    yourstring = 1 & 2

    Hope This Helps...

  3. #3
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Use the Val function.
    VB Code:
    1. Dim str1 As String
    2. Dim str2 As String
    3.  
    4. str1 = "1"
    5. str2 = "2"
    6.  
    7. MsgBox Val(str1) + Val(str2)
    Best regards

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