![]() |
Passing a TextBox Object
Hi all,
txtCorActDue1 is one of TextBox on a form and FillDateIn is a procedure used to fill date in the textbox when enter event happens, but when FillDateIn is call like the following, there is alway a type mismatch error. I guess txtCorActDue1 default value is text but how can I designate an object instead of its default value passed? Clara Private Sub txtCorActDue1_Enter() FillDateIn txtCorActDue1 End Sub Private Sub FillDateIn(txBox As TextBox) txBox.text = Year(FormatDateTime(14 + Now(), vbShortDate)) & "/" & _ Month(FormatDateTime(14 + Now(), vbShortDate)) & "/" & _ Day(FormatDateTime(14 + Now(), vbShortDate)) End Sub |
Passing a TextBox Object
Try this:
Private Sub FillDateIn(TxBox As MSForms.TextBox) RBS "clara" wrote in message ... Hi all, txtCorActDue1 is one of TextBox on a form and FillDateIn is a procedure used to fill date in the textbox when enter event happens, but when FillDateIn is call like the following, there is alway a type mismatch error. I guess txtCorActDue1 default value is text but how can I designate an object instead of its default value passed? Clara Private Sub txtCorActDue1_Enter() FillDateIn txtCorActDue1 End Sub Private Sub FillDateIn(txBox As TextBox) txBox.text = Year(FormatDateTime(14 + Now(), vbShortDate)) & "/" & _ Month(FormatDateTime(14 + Now(), vbShortDate)) & "/" & _ Day(FormatDateTime(14 + Now(), vbShortDate)) End Sub |
All times are GMT +1. The time now is 08:58 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com