我是vb.net的新手,我正在尝试开发衡器应用程序。我一直停留在串行端口一次读取多次的阶段,但我只想从串行端口获取最后读取的值港口。请参考以下代码和屏幕截图。提前致谢。我使用了以下代码:
$('.qty_input').keyup(function () {
var qtyValue = $('.qty_input').val();
// these 4 statements are executed no matter what.
// there is no point in duplicating them in each if-then block
for(var i=1; i<=4; i++) {
if ($('option[value="'+i+'"]').parent("span").length) {
$('option[value="'+i+'"]').unwrap('<span/>');
}
}
// the pattern for the next part is simple
// execute 4 statements of jQuery but exclude one part per each if-then block
if (qtyValue >= number1 && qtyValue <= number10) { exclude(1); }
else if (qtyValue >= number2 && qtyValue <= number20) { exclude(2); }
else if (qtyValue >= number3 && qtyValue <= number30) { exclude(3); }
else if (qtyValue >= number4 && qtyValue <= 999999) { exclude(4); }
function exclude(num) {
// loop from 1 to 4 to execute the same for each part
// but only exclude the one statement that is passed
// into the function
for(var i=1; i<=4; i++) {
if(i!=num) {
if (!$('option[value="'+i+'"]').parent("span").length) {
$('option[value="'+i+'"]').wrap('<span/>')
}
}
}
}
});