|
-
Mar 9th, 2000, 08:29 PM
#1
Thread Starter
New Member
I have 2 forms: FormA and FormB.
FormB contains a calendar and an OK button. FormB contains
a text box. When user choose a day from the calendar, and
click OK, I need the date from the calendar to be displayed in formB's text box. Do I have to declare a variable in a
module (to make it global) to handle that? other suggestion??
Thanks
-
Mar 9th, 2000, 08:44 PM
#2
Frenzied Member
To refer to a control on another form just use the form name and a . before the control name;
eg;
FormName.TextBox1.Text = "Hello"
so, in your example, the FormA button click event should be;
Sub CommandButton1_Click
FormB.TextBox1.Text = Calendar1.Value
End Sub
I've never used the calendar control so I'm not convinced .Value is the right property - if it isn't just change it to the appropriate property to retrieve the date.
'Buzby'
Visual Basic Developer
"I'm moving to Theory. Everything works there."
-
Mar 9th, 2000, 08:44 PM
#3
Frenzied Member
To refer to a control on another form just use the form name and a . before the control name;
eg;
FormName.TextBox1.Text = "Hello"
so, in your example, the FormA button click event should be;
Sub CommandButton1_Click
FormB.TextBox1.Text = Calendar1.Value
End Sub
I've never used the calendar control so I'm not convinced .Value is the right property - if it isn't just change it to the appropriate property to retrieve the date.
'Buzby'
Visual Basic Developer
"I'm moving to Theory. Everything works there."
-
Mar 9th, 2000, 08:45 PM
#4
Frenzied Member
To refer to a control on another form just use the form name and a . before the control name;
eg;
FormName.TextBox1.Text = "Hello"
so, in your example, the FormA button click event should be;
Sub CommandButton1_Click
FormB.TextBox1.Text = Calendar1.Value
End Sub
I've never used the calendar control so I'm not convinced .Value is the right property - if it isn't just change it to the appropriate property to retrieve the date.
'Buzby'
Visual Basic Developer
"I'm moving to Theory. Everything works there."
-
Mar 9th, 2000, 08:45 PM
#5
Frenzied Member
To refer to a control on another form just use the form name and a . before the control name;
eg;
FormName.TextBox1.Text = "Hello"
so, in your example, the FormA button click event should be;
Sub CommandButton1_Click
FormB.TextBox1.Text = Calendar1.Value
End Sub
I've never used the calendar control so I'm not convinced .Value is the right property - if it isn't just change it to the appropriate property to retrieve the date.
'Buzby'
Visual Basic Developer
"I'm moving to Theory. Everything works there."
-
Mar 9th, 2000, 08:47 PM
#6
New Member
It's easier than you think
From your question, it seems that all you need to do is to call your FormB as your parent object. Let me give you an example:
On FormA:
private sub Command1_Click
FormB.Text1.text = "Hello World!"
end sub
It's as easy as that.
How this helps
JFDman
-
Mar 9th, 2000, 08:50 PM
#7
Hyperactive Member
Buzb is right (all 4 times :-)), the .VALUE property is the correct one to reference. But instead of using:
Code:
Sub CommandButton1_Click
FormB.TextBox1.Text = Calendar1.Value
End Sub
it's better to use:
Code:
Sub CommandButton1_Click
FormB!TextBox1.Text = Calendar1.Value
End Sub
If I remember correctly, the ! tells it that it is a control. the . can also be used to reference Variables. I can't remember who told me that though :-)
Buzby - you hit the SUBMIT button too many times didn't you? :-)
Edited by netSurfer on 03-10-2000 at 08:51 AM
-
Mar 9th, 2000, 08:52 PM
#8
Thread Starter
New Member
Variable
That is what I needed, thanks
From your question, it seems that all you need to do is to call your FormB as your parent object. Let me give you an example:
On FormA:
private sub Command1_Click
FormB.Text1.text = "Hello World!"
end sub
It's as easy as that.
How this helps
JFDman
-
Mar 9th, 2000, 08:54 PM
#9
Thread Starter
New Member
Variable
That is what I needed, thanks
To refer to a control on another form just use the form name and a . before the control name;
eg;
FormName.TextBox1.Text = "Hello"
so, in your example, the FormA button click event should be;
Sub CommandButton1_Click
FormB.TextBox1.Text = Calendar1.Value
End Sub
I've never used the calendar control so I'm not convinced .Value is the right property - if it isn't just change it to the appropriate property to retrieve the date.
-
Mar 9th, 2000, 10:38 PM
#10
Frenzied Member
To refer to a control in another form use the form's name before the control name (seperated with a .)
eg;
FormName.TextBox1.Text = "hello"
in your example - although I have never used the calendar control so .Value may not be the right property;
Private Sub CommandButton1_Click
FormB.TextBox1.Text = Calendar1.Value
End Sub
'Buzby'
Visual Basic Developer
"I'm moving to Theory. Everything works there."
-
Mar 9th, 2000, 10:38 PM
#11
Frenzied Member
To refer to a control in another form use the form's name before the control name (seperated with a .)
eg;
FormName.TextBox1.Text = "hello"
in your example - although I have never used the calendar control so .Value may not be the right property;
Private Sub CommandButton1_Click
FormB.TextBox1.Text = Calendar1.Value
End Sub
'Buzby'
Visual Basic Developer
"I'm moving to Theory. Everything works there."
-
Mar 9th, 2000, 10:39 PM
#12
Frenzied Member
To refer to a control in another form use the form's name before the control name (seperated with a .)
eg;
FormName.TextBox1.Text = "hello"
in your example - although I have never used the calendar control so .Value may not be the right property;
Private Sub CommandButton1_Click
FormB.TextBox1.Text = Calendar1.Value
End Sub
'Buzby'
Visual Basic Developer
"I'm moving to Theory. Everything works there."
-
Mar 9th, 2000, 10:41 PM
#13
Frenzied Member
What the hell is going on.. I did indeed hit the submit button a few times but the message never appeared on the bulletin board so I did that old 'user-favourite' of trying again.. and whaddya know - suddenly they all appeared.
Sorry...
'Buzby'
Visual Basic Developer
"I'm moving to Theory. Everything works there."
-
Mar 9th, 2000, 10:50 PM
#14
Hyperactive Member
that's ok Mark - we forgive you. After all it's friday! :-)
-
Mar 10th, 2000, 04:33 AM
#15
Fanatic Member
Buzby,
You know that you can delete those extra posts if you want, don't you?
All the best.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|