There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen blue screen blue screen of death boot computer connection crash css dell display driver drivers email error excel firefox firefox 3 game hard drive internet internet explorer itunes laptop malware monitor network networking nvidia outlook outlook 2003 outlook express partition password printer problem router security slow software sound sprtcmd.exe startup trojan usb virus vista windows windows xp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
VB6 Help with control arrays


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
m8hee's Avatar
Junior Member with 17 posts.
 
Join Date: Apr 2004
27-May-2006, 11:22 AM #1
VB6 Help with control arrays
Hi,
I am trying to teach myself VB6. The problem I have is regarding control arrays and option buttons. I have one form with an array of option buttons (1 to 10) on it and another form with a label on it that I would like to fill with the caption from the selected option button. Does anyone know how I would do this?

Thanks
Sideshow_Bob's Avatar
Senior Member with 103 posts.
 
Join Date: Jul 2005
Experience: Intermediate
28-May-2006, 11:39 AM #2
I recently switched to VB 2005 and it got rid of control arrays. It also lets you do things so much easier, so I may not be too helpful.

Try finding a method for the option control array named something along the lines of "Changed" or "SelectionChanged". Then in this method try something like this:

<name of form with label>.<label name>.Text = <control array name>.Selected.Text
m8hee's Avatar
Junior Member with 17 posts.
 
Join Date: Apr 2004
29-May-2006, 10:18 AM #3
Thanks bob,
What I have tried is this:
dim loopvar as integer
dim room as string

lblroom.caption = ""
for loopvar = 0 to 9
If frmmain.option1(loopvar).value = 1 then
frmmain.option1.caption = room
lblroom.caption = room

end if

I don't get any errors but the lblroom.caption remains blank.

next loopvar
asbo's Avatar
Senior Member with 510 posts.
 
Join Date: Sep 2001
Location: who really knows anymore?
Experience: Advanced
29-May-2006, 04:22 PM #4
This is actually MUCH less difficult than you're trying to make it.

For this, I created two forms (Form1, Form2); ten OptionButtions in Form1 [Option1(0) to Option1(9)]; one Label in Form2 (Label1). Here's all my code, just paste it into Form1:
Code:
Private Sub Form_Load()
    Form2.Show
End Sub

Private Sub Option1_Click(Index As Integer)
    Form2.Label1 = Index
End Sub
In this demo, Form2.Label1 simple displays the index of which OptionButton is selected; in your case, you need to change that line to:
Code:
    Form2.Label1 = Option1(Index).Caption
and you're all set.

If you have any further questions, lemme know


asbo
__________________
·· ħþø ··
-----
- User Friendly by Illiad -
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 09:04 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.