|
-
Sep 23rd, 2000, 10:51 PM
#1
Thread Starter
Junior Member
Hello all...
Just started taking interest in VB... My question is how do you code form1's optionbox value to show it's caption in form2??? I did add a module and declared the connector but it's not working.... can anybody help me out on this.... my lab is due Tuesday (9.24.00)...
Thanks,
Eena
Eena

-
Sep 23rd, 2000, 10:57 PM
#2
Try this:
[code]
Origionally by Eena
Just started taking interest in VB... My question is how do you code form1's optionbox value to show it's caption in form2??? I did add a module and declared the connector but it's not working.... can anybody help me out on this.... my lab is due Tuesday (9.24.00)...
Form2:
[/quote]
if form1.option1.value then
msgbox form1.option1.caption
end if
-
Sep 23rd, 2000, 11:07 PM
#3
Frenzied Member
Welcome to the forums Eena 
If you have your code in an event in Form1, you can use this kind of thing:
Form2.Label1.Caption = Option1.Caption
which is a short way of writing this:
Form2.Label1.Caption = Form1.Option1.Caption
Basically if you are writing code in a form, the compiler looks for the object you are identifying (eg Label1) in the local form if you don't specify which form it's in. Obviously if it can't find it there is an error. If you specify which form the object is in (eg Form2.Label1) then the compiler should find it okay.
It's because a form is an object, which contains other objects (like labels and option buttons), which contain their own properties (like Caption and Name). All this is specified using the dot (.) or direct member access operator. It sounds complicated but it's not, you've been using it all the time after all 
Harry.
"From one thing, know ten thousand things."
-
Sep 23rd, 2000, 11:40 PM
#4
Thread Starter
Junior Member
Thanks for your prompt response... I applied the form2.label1.caption=option1.caption... and it gave me an error message of object required.. what did i do wrong?
Here's my code:
Dim strProcessor As String
strProcessor = lblProcessor.Caption
If optWC700.Value = True Then
frmReceipt.lblProcessor.Caption = optWC700.Caption
End If
If optWC500.Value = True Then
frmReceipt.lblProcessor.Caption = optWC500.Caption
End If
If optWC800.Value = True Then
frmReceipt.lblProcessor.Caption = optWC800.Caption
End If
If optWC1000.Value = True Then
frmReceipt.lblProcessor.Caption = optWC1000.Caption
End If
End Sub
Eena

-
Sep 23rd, 2000, 11:43 PM
#5
If optW C100 0.Value = True Then
frmReceipt.lblProcessor.Caption = optW C100 0.Caption
End If
optWC1000 should have no spaces .
Try removing them...
-
Sep 23rd, 2000, 11:54 PM
#6
Thread Starter
Junior Member
I'm sorry i sound so dumb... i fixed the spaces but it still gave me the error: object required...
do i need to declare the optWC700 as object???
Eena

-
Sep 25th, 2000, 10:51 PM
#7
Code:
'Your code
Dim strProcessor As String
strProcessor = lblProcessor.Caption '<-- Error
If optWC700.Value = True Then
frmReceipt.lblProcessor.Caption = optWC700.Caption
End If
If optWC500.Value = True Then
frmReceipt.lblProcessor.Caption = optWC500.Caption
End If
If optWC800.Value = True Then
frmReceipt.lblProcessor.Caption = optWC800.Caption
End If
If optW C100 0.Value = True Then
frmReceipt.lblProcessor.Caption = optW C100 0.Caption
End If
End Sub
strProcessor = [frmReceipt.]lblProcessor.Caption
You forgot the frmReceipt. at that line.
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
|