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. need help calculator do not accept more than max char on textbox

need help calculator do not accept more than max char on textbox

Scheduled Pinned Locked Moved Visual Basic
helptutorialquestion
9 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.
  • V Offline
    V Offline
    vblearner09
    wrote on last edited by
    #1

    I try to fix the small problems that my calculator has For example, if I type 78/3=26 (all this from keyboard) This is what I want the program to work.. If I type 78 from keyboard with "/" (divide) and 3.. when I hit "ENTER" from keyboard. I should get 26... my current calculator doesn't accept "/" (divide) and ENTER to give result if found this code online, can someone try to fix or tell me how to make the code below work for my problem code: Private Sub txt_KeyPress(ByVal KeyAscii As Integer) If Not IsNumeric(Chr(KeyAscii)) And KeyAscii <> 13 _ And KeyAscii <> 45 And KeyAscii <> 8 Then KeyAscii = 109 End If End Sub My second problem on my calculator: I want to check if the number enter to textbox is the at end of textbox, then it give me a beep sound...and do not accept any more numeratic number (1-9)...and the beep sound when the user try to press any number 1-9. my current code doesn't work...please help me and see my code below. how to fix the code below that will work for me? If TxtDisplay.MaxLength = "27" Then '27 means the only max number 'can enter in textbox TxtDisplay.Enabled End If I appreciated all the great help you can provide!!!! This code is done in VB 2008

    C 1 Reply Last reply
    0
    • V vblearner09

      I try to fix the small problems that my calculator has For example, if I type 78/3=26 (all this from keyboard) This is what I want the program to work.. If I type 78 from keyboard with "/" (divide) and 3.. when I hit "ENTER" from keyboard. I should get 26... my current calculator doesn't accept "/" (divide) and ENTER to give result if found this code online, can someone try to fix or tell me how to make the code below work for my problem code: Private Sub txt_KeyPress(ByVal KeyAscii As Integer) If Not IsNumeric(Chr(KeyAscii)) And KeyAscii <> 13 _ And KeyAscii <> 45 And KeyAscii <> 8 Then KeyAscii = 109 End If End Sub My second problem on my calculator: I want to check if the number enter to textbox is the at end of textbox, then it give me a beep sound...and do not accept any more numeratic number (1-9)...and the beep sound when the user try to press any number 1-9. my current code doesn't work...please help me and see my code below. how to fix the code below that will work for me? If TxtDisplay.MaxLength = "27" Then '27 means the only max number 'can enter in textbox TxtDisplay.Enabled End If I appreciated all the great help you can provide!!!! This code is done in VB 2008

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You are utterly lost. 1 - you have code to only accept numbers. The code is crap, but it will work. You need to add code to accept the /, etc, as well as writing code to parse what is entered. Your best bet is to store numbers as you detect a modifier, then work on them from there. 2 - Again, you are lost. You can set the max length property, but it's not going to be a string, surely ? Either way, setting the max length is all you need to do, unless your code from question 1 actually stops accepting numbers after a certain length. Overall, it looks like you're grabbing code off the web and guessing. If you're doing a class, read your book. If you're teaching yourself, buy a book.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      V 1 Reply Last reply
      0
      • C Christian Graus

        You are utterly lost. 1 - you have code to only accept numbers. The code is crap, but it will work. You need to add code to accept the /, etc, as well as writing code to parse what is entered. Your best bet is to store numbers as you detect a modifier, then work on them from there. 2 - Again, you are lost. You can set the max length property, but it's not going to be a string, surely ? Either way, setting the max length is all you need to do, unless your code from question 1 actually stops accepting numbers after a certain length. Overall, it looks like you're grabbing code off the web and guessing. If you're doing a class, read your book. If you're teaching yourself, buy a book.

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

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

        I am new to VB and try to learn new language. Please be patient with me. you can read all the books, but you don't get real hand on practice in programming in VB. practice in VB is the way to go.(learn programming). i learn to programming in VB with doing it not watching the code. I saw the code online..and try to modify that work to my need...i stuck and found the sample online.....to fix for my need... can someone give me the sample code that will work to the problem that i describe on the original forum? -Andy Thanks

        C 1 Reply Last reply
        0
        • V vblearner09

          I am new to VB and try to learn new language. Please be patient with me. you can read all the books, but you don't get real hand on practice in programming in VB. practice in VB is the way to go.(learn programming). i learn to programming in VB with doing it not watching the code. I saw the code online..and try to modify that work to my need...i stuck and found the sample online.....to fix for my need... can someone give me the sample code that will work to the problem that i describe on the original forum? -Andy Thanks

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          vblearner09 wrote:

          . you can read all the books, but you don't get real hand on practice in programming in VB.

          No. But, by trying to write code when you have no idea, you learn nothing, either. You should read a book and do the exercises in the book, so you learn by applying things you know, not by copying and pasting code off the web, and asking us to fix it because you have no idea what it does.

          vblearner09 wrote:

          can someone give me the sample code that will work to the problem that i describe on the original forum?

          I'm sorry, I thought you said you wanted to learn ? You don't want to read a book, what would make me think you would read the code, rather than copy and paste it ? There is no substitute for knowledge. Knowledge is different to guessing. Please buy a book and work through it,

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          V 1 Reply Last reply
          0
          • C Christian Graus

            vblearner09 wrote:

            . you can read all the books, but you don't get real hand on practice in programming in VB.

            No. But, by trying to write code when you have no idea, you learn nothing, either. You should read a book and do the exercises in the book, so you learn by applying things you know, not by copying and pasting code off the web, and asking us to fix it because you have no idea what it does.

            vblearner09 wrote:

            can someone give me the sample code that will work to the problem that i describe on the original forum?

            I'm sorry, I thought you said you wanted to learn ? You don't want to read a book, what would make me think you would read the code, rather than copy and paste it ? There is no substitute for knowledge. Knowledge is different to guessing. Please buy a book and work through it,

            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

            V Offline
            V Offline
            vblearner09
            wrote on last edited by
            #5

            What good book you recommend to buy in VB that has a lot of example? Since you seem to know about programming in VB, what book would you recommend? my calculator program works on most the part... -Andy

            C 1 Reply Last reply
            0
            • V vblearner09

              What good book you recommend to buy in VB that has a lot of example? Since you seem to know about programming in VB, what book would you recommend? my calculator program works on most the part... -Andy

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              I don't know, it's been so long since I learned ( and I learned C# ). I would look at Amazon for a book that has a lot of good reviews. I'd tend towards a 'teach yourself in 24 hours' type book, so you start with the basics.

              Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

              V 1 Reply Last reply
              0
              • C Christian Graus

                I don't know, it's been so long since I learned ( and I learned C# ). I would look at Amazon for a book that has a lot of good reviews. I'd tend towards a 'teach yourself in 24 hours' type book, so you start with the basics.

                Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                V Offline
                V Offline
                vblearner09
                wrote on last edited by
                #7

                can someone explain what e.Handled = True does? -Andy

                C 1 Reply Last reply
                0
                • V vblearner09

                  can someone explain what e.Handled = True does? -Andy

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #8

                  If you bought a book, it would explain it. If you googled it, that would work to. Some event handlers pass an event args with a 'handled' property. If you set it to true, the event is marked as handled and no further processes occur.

                  Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                  V 1 Reply Last reply
                  0
                  • C Christian Graus

                    If you bought a book, it would explain it. If you googled it, that would work to. Some event handlers pass an event args with a 'handled' property. If you set it to true, the event is marked as handled and no further processes occur.

                    Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

                    V Offline
                    V Offline
                    vblearner09
                    wrote on last edited by
                    #9

                    Thanks!!1

                    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