只读两个正确的字符。 [英] read only two correct characters.

查看:57
本文介绍了只读两个正确的字符。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

This method helps me to read with a scanner, he only needs to read the ones that begin with "3S" and "3s",

删除这两个字符("3S")并复制其余的读数。一个不同的代码,

remove these two characters ("3S") and copy the rest of the reading. a different code,

没有带来"3S",我需要的是它读取文本框中的读数,

that does not bring "3S", what I need is that it reads the reading in the textbox,

但它没有带来删除的条件阅读并说出"错误的代码"。

but it does not bring the condition that erases the reading and says "incorrect code".

private void opcion1(TEX TBOX txt)
{
string s = txt.Text;
string a =" 3S" ;;
string b =" 3s" ;;

if(s!="")
{
if(s.Length> = 2)
{
if(s。 StartsWith(a)|| s.StartsWith(b))
{
if(s.Length> 2)
{
//MessageBox.Show(s.Length。的ToString());
s = s.Substring(2);
}
其他
s ="" ;;
}

txt.Text = s;
}
}

}




推荐答案

对我来说似乎有点合理,如果有点冗长。如果文本框中的值以3S开头,则表示您正在将其剥离并将文本框设置回该值。我假设您在这里部分复制了代码,因为方法声明不正确,否则
看起来是合理的。

Seems reasonable to me, if a little verbose. If the value in the textbox starts with 3S then you are stripping it out and setting the textbox back to that value. I assume you partially copied code here because the method declaration isn't right but otherwise it seems reasonable.

如果您收到错误,请发布错误。如果您根本没有得到预期的响应,请发布您提供的输入。单步执行代码也可以揭示问题所在。

If you're getting an error then please post the error. If you're simply not getting the response you expected then post what input you are giving it. Stepping through the code would also reveal what the issue is.


这篇关于只读两个正确的字符。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆