I have a problem with date and time picker when i select the date from dtpicker1 then txtdate1 gets the value but when i debug it shows txtdate1 = "" why please help

Private Sub DTPicker1_CloseUp()
txtdate1.Text = DTPicker1.Value
DTPicker1.Refresh
End Sub

Maybe it's because you place your code at the CloseUp event of the date picker, it seems that when the CloseUp event is being fired, the Value property still doesn't have the date selected...

why not change the event?, try to put it in LostFocus or Click events of the date picker...

I have tried both but didn't help me

Remove the refresh statement, it should solve your problem. Also, as PoisenedHeart pointed out, under your click event.

Also check your code that you are not calling a clean up of all text in your text boxes.

How should i call clean up method sorry i didn't understand??

No, you won't call clean up, just check if you do not have it in your code somewhere in the form -"Text1.Text = "" or Text1.Text = vbNullString".

This is also maybe why your textbox is cleared. If you do not have it, don't worry about it.:)

Its showing the date in textbox but when i click on calculate button it gives message invalid use of null but when i pass dates manually and click on calculate button then it perform calculation

The error "Invalid use of Null" means that you are trying to divide a number by zero.

Write some error trapping code just before the calculation -

If Text1.Text = vbNullString Then
msgbox "Add a number/date"
Else
'Do calculation
End If

Dear AndreRet i have resolved the problem by using validate event now it is working perfectly any way thanks for your kind and great help

My pleasure. Happy coding.:)

Have a wonderful new year.:)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.