如何验证开始和结束月份 [英] How to validate starting and ending month

查看:74
本文介绍了如何验证开始和结束月份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



在我的应用程序中,我有2个组合框,其中包含月份名称,例如Jan,Feb .... Dec



现在我必须检查起始月份是否应该大于结束月份



例如如果用户在第一个组合中选择 Dec 并在第二个组合框中选择 Jan ,则应该给出错误。



请告诉我如何进行验证。



谢谢..

Hi all

In my application i have 2 combo box which contains month name like Jan, Feb....Dec

Now i have to check that the starting month should not be greater than ending month

e.g. if user selects Dec in first combo and select Jan in second combo box, then it should give an error.

Please tell me how to do the validation for this.

Thank you..

推荐答案

首先,请看我对这个问题的评论。



按照自然顺序添加月份,1月到12月。 item的索引将索引月份0到11.比较两个控件的选定索引。



-SA
First, please see my comment to the question.

Add months in natural order, January to December. The indices of item will index the months 0 to 11. Compare selected indices of the two controls.

—SA






当您使用数据绑定组合框时,每个记录都有值feild.

你可以使用这个值来验证
Hi,

When you bind the combobox with the data you have value feild associate to each record.
You can use this values to validate


我自己做了。



i转换组合框月份值并进行比较。< br $> b $ b

I did it by my self.

i converted the combo box month value and compared.

Dim a As Integer = Convert.ToDateTime("01-" & cmbFMonth.Text & "-1900").Month
Dim b As Integer = Convert.ToDateTime("01-" & cmbTMonth.Text & "-1900").Month





全部谢谢..



Thanks all..


这篇关于如何验证开始和结束月份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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