Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How can I convert a text to integer

How can I convert a text to integer

Scheduled Pinned Locked Moved Visual Basic
questionhelp
5 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    meki_2118
    wrote on last edited by
    #1

    hi. how can I convert a string to integer? I'm doing a program in VB were you are required to input a mathematical formula in a single input box and value each of the integer. But when I use the Left command, the formula of the textbox are converted into string type and won't compute the value as in the formula indicated. I really need your help. thanks..

    D V P 3 Replies Last reply
    0
    • M meki_2118

      hi. how can I convert a string to integer? I'm doing a program in VB were you are required to input a mathematical formula in a single input box and value each of the integer. But when I use the Left command, the formula of the textbox are converted into string type and won't compute the value as in the formula indicated. I really need your help. thanks..

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      There is nothing built into VB.NET or the .NET Framework that's going to evaluate expressions typed into a textbox. You have to create your own expression parsing engine to break the input down into something you can do the math on, piece-by-piece. Google for "Reverse Polish Notation" for an intro to expression engines. There are certainly other implementations to do this, but RPN is good place to start.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007

      1 Reply Last reply
      0
      • M meki_2118

        hi. how can I convert a string to integer? I'm doing a program in VB were you are required to input a mathematical formula in a single input box and value each of the integer. But when I use the Left command, the formula of the textbox are converted into string type and won't compute the value as in the formula indicated. I really need your help. thanks..

        V Offline
        V Offline
        V 2
        wrote on last edited by
        #3

        Hi, If U want to convert text in to integer then simply U can use it:- dim s as string dim i as integer s="200" i=val(s) 'This function converts the string in integer Best Of Luck:rose:

        C 1 Reply Last reply
        0
        • V V 2

          Hi, If U want to convert text in to integer then simply U can use it:- dim s as string dim i as integer s="200" i=val(s) 'This function converts the string in integer Best Of Luck:rose:

          C Offline
          C Offline
          Colin Angus Mackay
          wrote on last edited by
          #4

          Did you read the OP's question? He said the text box contains a "mathematical formula".


          Upcoming FREE developer events: * Developer! Developer! Developer! 6 * Developer Day Scotland My website

          1 Reply Last reply
          0
          • M meki_2118

            hi. how can I convert a string to integer? I'm doing a program in VB were you are required to input a mathematical formula in a single input box and value each of the integer. But when I use the Left command, the formula of the textbox are converted into string type and won't compute the value as in the formula indicated. I really need your help. thanks..

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #5

            Have you considered looking at this[^] article to get an understanding on evaluating formulae in a textbox. I know it's in C#, but using a tool like Reflector it's relatively simple to revert the IL into VB.NET.

            Deja View - the feeling that you've seen this post before.

            My blog | My articles

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups