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. string convert to operator

string convert to operator

Scheduled Pinned Locked Moved Visual Basic
helpquestion
3 Posts 2 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.
  • D Offline
    D Offline
    dimuthuvbnet
    wrote on last edited by
    #1

    Dear All, I have a problem If I insert values from text boxes as 3, +, 2 and I catch it for string variables. a = textbox1.text b = textboxt2.text c = textbox3.text Then I want to calculate those values ex: total = 3+2 virtually, total = a b c (because b="+") How can I do this, please help Thanks

    F 1 Reply Last reply
    0
    • D dimuthuvbnet

      Dear All, I have a problem If I insert values from text boxes as 3, +, 2 and I catch it for string variables. a = textbox1.text b = textboxt2.text c = textbox3.text Then I want to calculate those values ex: total = 3+2 virtually, total = a b c (because b="+") How can I do this, please help Thanks

      F Offline
      F Offline
      Fu Manchu
      wrote on last edited by
      #2

      want you have here is a casting problem. i guess that you want have the option to have different operators in the in 'b' so you could do basic maths operation....+ \ - * if this is so...what i would so is have b a dropdownlist or combobox with the selection fixed and maybe have it defaulted to '+' the next thing to do if make textbox 'a' and 'c' only except numbers, you can find many example of this on the web and once you have done this because you know that only number are going be entered you can cast the strings to ints i.e. Dim int1 As Integer = CType(textbox1, Integer) Dim int2 As Integer = CType(textbox3, Integer) then based on the selection do a case select to do the calculation hope this is what you wanted....

      D 1 Reply Last reply
      0
      • F Fu Manchu

        want you have here is a casting problem. i guess that you want have the option to have different operators in the in 'b' so you could do basic maths operation....+ \ - * if this is so...what i would so is have b a dropdownlist or combobox with the selection fixed and maybe have it defaulted to '+' the next thing to do if make textbox 'a' and 'c' only except numbers, you can find many example of this on the web and once you have done this because you know that only number are going be entered you can cast the strings to ints i.e. Dim int1 As Integer = CType(textbox1, Integer) Dim int2 As Integer = CType(textbox3, Integer) then based on the selection do a case select to do the calculation hope this is what you wanted....

        D Offline
        D Offline
        dimuthuvbnet
        wrote on last edited by
        #3

        Thank you very much Fu Manchu, Yes, it is ok for a and c. But how can I include b ("+" or may be "-", "*", "/" something like that). Becuase the operator is as in the textbox text, therefore I want to it convert to operator and also, include into equation. Is it possible?? If I describe further, there are three texboxes in the application. So user can type values in 1st and 3rd textboxes and operator (may be one of these +, -, *, /) in 2nd text box. Then application should give the results. help me, Thanks

        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