Prevent typing string in edit text
古いコメントを表示
I have a problem. I want to create a edit text and then when I type a string in it, it will display nothing like a empty. That is to say it allows only numbers. I found some ways but they use push button for checking. Please help me.
Thank you in advance.
採用された回答
その他の回答 (3 件)
Walter Roberson
2016 年 3 月 31 日
0 投票
You can use a variation of http://www.mathworks.com/matlabcentral/fileexchange/24861-41-complete-gui-examples/content/GUI_37.m
Daveed Daveed
2022 年 7 月 31 日
Hello. i was walking around here and i thought the following solution might be usefull for future people (may be the past time traveler :) )
function prevent_string(textbox_control)
if textbox_control.String ~= "" && isnan(str2double(textbox_control.String))
textbox_control.String = "";
end
Walter Roberson
2022 年 7 月 31 日
These days you would use a
uieditfield('numeric')
which requires uifigure() (and will not work for traditional figures)
カテゴリ
ヘルプ センター および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!