Hello, I need to place into a textbox of a form the current month such as 10 for october 11 for november when I update a database. I also need to place into another textbox the current year. Can anyone help?
Text1.Text = Format(Now(), "mm") Text2.Text = Format(Now(), "yy") ' or "YYYY"
Tips, Examples & Tutorials: A valuable forum tool • Generate unique TreeView keys • TreeView with "open" and "closed folder" icons • Time code using GetTickCount • How to trap the Tab key • Scroll a form • NumberBox ActiveX control • Color a ListView row • An InputBox form • How to use SaveSetting and GetSetting • A program registration scheme • Spellcheck a Textbox • Resize controls • Open Windows Explorer at Last Visited Path • A Blackjack Game • Count lines of code • Private Message Viewer • Copy/Paste VB Code • Paste VB Code Add-In • Insert Procedure Names Add-In • A calculator for the game of Spider • My review of REALbasic 2008 • VB6 Debug Tutorial • Picture/Video Viewer • VBF Photo Contest Winners 2009 - 2016
This is what I have now. I get a "Sub or Function not defined" error. VB Code: txtfield(3) = Format(Now(), "mm") txtfield(4) = Format(Now(), "yyyy")
txtfield(3) = Format(Now(), "mm") txtfield(4) = Format(Now(), "yyyy")
Assuming that txtfield(3) and txtfield(4) are two textboxes in a control array, your code should be OK. What is highlighted when you get the error?
Are your textboxes named txtfield or txtfields or something else? If the name wasn't correct you'd get that error.
Maritin, You were right, I forgot the "s" in txtfields. Thanks
Forum Rules