如何获取date点击monthview我的文本框上的userform?
Private Sub MonthView1_DateClick(ByVal DateClicked As Date) Txt_Prod_Loc_Date.Value = MonthView1.Value Unload Me End Sub Private Sub FrmCalendar_Initialize() Unload Me End Sub
我也试过Txt_Prod_Loc_Date.Value = DateClicked。 但是我看到一个“运行时错误424,对象需要
谢谢
你可以同时使用; MonthView1.Value
或DateClicked
。 问题不是因为那:)
顺便说一句,为什么你有Unload Me
在FrmCalendar_Initialize()
? 这会给你一个Run Time Error 91. Object Variable or With block variable Not set
您得到Runtime error 424, object required
因为它无法find您的用户Txt_Prod_Loc_Date
上的Txt_Prod_Loc_Date
控件。
如果该控件在工作表中,那么就像这样使用它
Private Sub MonthView1_DateClick(ByVal DateClicked As Date) Sheet1.TextBox1.Value = MonthView1.Value End Sub
如果该控件是以某种其他forms(比如Userform1
),那么就像这样使用它
Private Sub MonthView1_DateClick(ByVal DateClicked As Date) UserForm1.Txt_Prod_Loc_Date.Value = MonthView1.Value End Sub