need help calculator do not accept more than max char on textbox
-
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
-
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
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.
-
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.
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
-
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
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.
-
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.
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
-
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
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.
-
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.
can someone explain what e.Handled = True does? -Andy
-
can someone explain what e.Handled = True does? -Andy
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.
-
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.
Thanks!!1