Reputation: 29
I've created a program and I'm trying to make it a lot more efficient. There are textboxes in it requiring entries from the user. When all the required information is in, a report is being generated in another multiline textbox. It is really important that the Date shown in the generated report is of this format "dd/MM/yy". I've already used this code below :
Dim a as String
a = Format(Textbox1.text, "dd/MM/yy")
However the only thing this does is that when someone types the date with this format "dd-MM-yy" it converts it to the one one I want. But when someone uses "." (dd.MM.yy) or even " "(dd MM yy) it doesn't convert it. Is there a way for me to extract the characters from the entried date no matter how it is being written and convert it to the one I want ?
Upvotes: 1
Views: 1376
Reputation: 65421
Right click on the toolbox, select Components...
and scroll down to Microsoft Windows Common Controls-2 6.0 (SP6)
(or something similar). This will add more controls to the toolbox. The control you want to use is the DTPicker
control.
To get the date in your required format, use
Dim a As String
a = Format(DTPicker1.Value, "dd/MM/yy")
Upvotes: 3