简体   繁体   English

VB.NET-比较两个字母代码

[英]VB.NET - comparing a two letter code

I have an ASP.NET 4.0 application. 我有一个ASP.NET 4.0应用程序。 In the application we want to allow the user to select the revision of a document they've read. 在应用程序中,我们希望允许用户选择已阅读文档的修订版。

Right now the codes are along the lines of: 现在,代码如下:

AA AB AC BA BB BC AA AB AC BA BB BC

In this case, AA is revision one and BC is revision 6. 在这种情况下,AA是修订版1,而BC是修订版6。

What I want to do is check that the value a user is entering in a textbox is of the current revision or lower. 我想做的是检查用户在文本框中输入的值是当前版本或更低版本。

Is this as simple as a string comparison, or is there more to it? 这是像字符串比较一样简单,还是还有更多呢? I was thinking of using a CustomValidator and server-side code. 我当时在考虑使用CustomValidator和服务器端代码。

It doesn't sound like a simple string-comparison will do it: using your example above, "AZ" would sort before "BC". 听起来不像是简单的字符串比较:在上面的示例中,“ AZ”将排在“ BC”之前。 Thus, it would be considered "earlier" from a sorting perspective, but is probably not a valid value for the user to select. 因此,从排序的角度来看,它将被认为是“较早的”,但对于用户来说可能不是有效的值。

If you know all the valid revisions of the document at hand, you're probably better off simply confirming that the user's value is in the list. 如果您知道手头所有有效的文档修订版,那么最好只确认用户的值在列表中就可以了。 Or maybe even letting them choose (via DropDownList) only valid values, rather than letting them type in any ol' string. 或者甚至让他们选择(通过DropDownList)仅选择有效值,而不是让他们键入任何ol'字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM