vb.net中datetimepicker中的错误 [英] error in datetimepicker in vb.net

查看:82
本文介绍了vb.net中datetimepicker中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

dateTimePicker1.Format = DateTimePickerFormat.Custom
dateTimePicker1.CustomFormat = "MMMM yyyy" 
dateTimePicker1.ShowUpDown = True



我用过了上面的代码我需要相同的格式,例如。 2014年3月。它工作正常。但在一个月的31号,它显示了一个例外我如何处理或任何其他替代品

用于显示此格式



实际目的此代码是选择月份将月份更改为另一个月但是它仅在今天(10月31日)或任何月份的第31个


I have used the above code I need the same format eg. March 2014.It work correctly . But on the 31st of a month it show an exception how can I handle or any other alternatives
for showing this format

Actual purpose of this code is to select month the error occurs on changing the month to another But it only on today (31st october ) or 31st of any month having

推荐答案

此代码将但是如果它不超过28,它将不包含当前日期,如果你不需要保存这个适合你的日期。



This code will work but it will not contain the current date if it's bigger than 28, if you don't require to save the date this will work for you.

DateTimePicker1.Format = DateTimePickerFormat.Custom
    DateTimePicker1.CustomFormat = "MMMM yyyy"
    DateTimePicker1.ShowUpDown = True
    Dim getdate As String = My.Computer.Clock.LocalTime.Date.Day
    If getdate > 28 Then
        DateTimePicker1.Value = DateTimePicker1.Value.AddDays(-3)
    End If


这篇关于vb.net中datetimepicker中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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