Numeric TextBox

后端 未结 13 1133
再見小時候
再見小時候 2020-12-03 20:01

Im new to programming and I dont know very much about but I\'m making a calculator, and i want to use a textbox that only acepts numbers and decimals, and when the user past

13条回答
  •  孤街浪徒
    2020-12-03 20:30

    i would probably use a regular expression to screen out non-numerics.

    pseudo code:

    for (each item in the input string) {
       if (!match(some regular expression, item)) {
            toss it out
       } else {
            add item to text box or whatever you were going to do with it
       }
    
    }
    

提交回复
热议问题