Retrieve date from MsgBox to TextBox in other Form

Oscar VM

New Member
Joined
Feb 28, 2019
Messages
1
Hello, I got stuck on the following code that shows date selected from datepicker
Private Sub select_label(msForm_C As MSForms.Control)
'/* Capture the selected date */
Dim i As Integer, sel_date As Date
i = Split(msForm_C.Name, "_")(1) - 1
sel_date = FirstCalSun(curMonth) + i


'/* Transfer the date where you want it to go */
MsgBox sel_date
End Sub

this datepicker is in UserForm2, I algo have one TextBox in UserForm1 with the following code

Private Sub TextBox1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
SelectDate.Show


End Sub


I need to send data from sel_date to TextBox1 located on UserForm1
how can I do that?
appreciate your help
Oscar VM
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Try this

Code:
[COLOR=#333333]Private Sub select_label(msForm_C As MSForms.Control)[/COLOR]
[COLOR=#333333]'/* Capture the selected date */[/COLOR]
[COLOR=#333333]Dim i As Integer, sel_date As Date[/COLOR]
[COLOR=#333333]i = Split(msForm_C.Name, "_")(1) - 1[/COLOR]
[COLOR=#333333]sel_date = FirstCalSun(curMonth) + i[/COLOR]

[COLOR=#0000ff]if sel_date <> "" then
      userform1.textbox1.value = sel_date
end if[/COLOR]

[COLOR=#333333]'/* Transfer the date where you want it to go */[/COLOR]
[COLOR=#333333]MsgBox sel_date[/COLOR]
[COLOR=#333333]End Sub[/COLOR]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,255
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top