Any way to make this easier?
Any way to make this easier?
Any way to make this easier?
Any way to make this easier?
Any way to make this easier?
Any way to make this easier? Any way to make this easier? Any way to make this easier? Any way to make this easier? Any way to make this easier? Any way to make this easier? Any way to make this easier? Any way to make this easier?
Any way to make this easier? Any way to make this easier?
Any way to make this easier?
Go Back  Xtreme Visual Basic Talk > > > Any way to make this easier?


Reply
 
Thread Tools Display Modes
  #1  
Old 10-24-2000, 01:59 PM
CornMaster's Avatar
CornMaster CornMaster is offline
Contributor
 
Join Date: Aug 2000
Location: St. John's, Newfoundland
Posts: 655
Default Any way to make this easier?


Is there any way to disable a group of 3 options in 1 group of 10 without having to type all this? Note: s1....s10 are options buttons, and ip1, gt1, d1, are text boxes. And each group of ip1, gt1, and d1 are on a frame p1...p10.
Private Sub s1_Click()
If s1.Value = True Then
ip1.Enabled = True And gt1(1).Enabled = True And d1.Enabled = True
ip2.Enabled = False And gt2.Enabled = False And d2.Enabled = False
ip3.Enabled = False And gt3.Enabled = False And d3.Enabled = False
ip4.Enabled = False And gt4.Enabled = False And d4.Enabled = False
ip5.Enabled = False And gt5.Enabled = False And d5.Enabled = False
ip6.Enabled = False And gt6.Enabled = False And d6.Enabled = False
ip7.Enabled = False And gt7.Enabled = False And d7.Enabled = False
ip8.Enabled = False And gt8.Enabled = False And d8.Enabled = False
ip9.Enabled = False And gt9.Enabled = False And d9.Enabled = False
ip10.Enabled = False And gt10.Enabled = False And d10.Enabled = False
End If
If s1.Caption = "Create" And s1.Value = True Then
p1.Visible = True
s1.Caption = "Select"
End If
If s1.Value = False And ip1.Text = "" Then
s1.Caption = "Create" And p1.Visible = False
End If
End Sub

Private Sub s10_Click()
If s10.Value = True Then
ip1.Enabled = False And gt1(1).Enabled = False And d1.Enabled = False
ip2.Enabled = False And gt2.Enabled = False And d2.Enabled = False
ip3.Enabled = False And gt3.Enabled = False And d3.Enabled = False
ip4.Enabled = False And gt4.Enabled = False And d4.Enabled = False
ip5.Enabled = False And gt5.Enabled = False And d5.Enabled = False
ip6.Enabled = False And gt6.Enabled = False And d6.Enabled = False
ip7.Enabled = False And gt7.Enabled = False And d7.Enabled = False
ip8.Enabled = False And gt8.Enabled = False And d8.Enabled = False
ip9.Enabled = False And gt9.Enabled = False And d9.Enabled = False
ip10.Enabled = True And gt10.Enabled = True And d10.Enabled = True
End If
If s10.Caption = "Create" And s10.Value = True Then
p10.Visible = True
s10.Caption = "Select"
End If
If s10.Value = False And ip10.Text = "" Then
s10.Caption = "Create" And p10.Visible = False
End If
End Sub

Private Sub s2_Click()
ip1.Enabled = False And gt1(1).Enabled = False And d1.Enabled = False
ip2.Enabled = True And gt2.Enabled = True And d2.Enabled = True
ip3.Enabled = False And gt3.Enabled = False And d3.Enabled = False
ip4.Enabled = False And gt4.Enabled = False And d4.Enabled = False
ip5.Enabled = False And gt5.Enabled = False And d5.Enabled = False
ip6.Enabled = False And gt6.Enabled = False And d6.Enabled = False
ip7.Enabled = False And gt7.Enabled = False And d7.Enabled = False
ip8.Enabled = False And gt8.Enabled = False And d8.Enabled = False
ip9.Enabled = False And gt9.Enabled = False And d9.Enabled = False
ip10.Enabled = False And gt10.Enabled = False And d10.Enabled = False
If s2.Caption = "Create" And s2.Value = True Then
p2.Visible = True
s2.Caption = "Select"
End If
If s2.Value = False And ip2.Text = "" Then
s2.Caption = "Create" And p2.Visible = False
End If
End Sub

Private Sub s3_Click()
If s3.Value = True Then
ip1.Enabled = False And gt1(1).Enabled = False And d1.Enabled = False
ip2.Enabled = False And gt2.Enabled = False And d2.Enabled = False
ip3.Enabled = True And gt3.Enabled = True And d3.Enabled = True
ip4.Enabled = False And gt4.Enabled = False And d4.Enabled = False
ip5.Enabled = False And gt5.Enabled = False And d5.Enabled = False
ip6.Enabled = False And gt6.Enabled = False And d6.Enabled = False
ip7.Enabled = False And gt7.Enabled = False And d7.Enabled = False
ip8.Enabled = False And gt8.Enabled = False And d8.Enabled = False
ip9.Enabled = False And gt9.Enabled = False And d9.Enabled = False
ip10.Enabled = False And gt10.Enabled = False And d10.Enabled = False
End If
If s3.Caption = "Create" And s3.Value = True Then
p3.Visible = True
s3.Caption = "Select"
End If
If s3.Value = False And ip3.Text = "" Then
s3.Caption = "Create" And p3.Visible = False
End If
End Sub

Private Sub s4_Click()
If s4.Value = True Then
ip1.Enabled = False And gt1(1).Enabled = False And d1.Enabled = False
ip2.Enabled = False And gt2.Enabled = False And d2.Enabled = False
ip3.Enabled = False And gt3.Enabled = False And d3.Enabled = False
ip4.Enabled = True And gt4.Enabled = True And d4.Enabled = True
ip5.Enabled = False And gt5.Enabled = False And d5.Enabled = False
ip6.Enabled = False And gt6.Enabled = False And d6.Enabled = False
ip7.Enabled = False And gt7.Enabled = False And d7.Enabled = False
ip8.Enabled = False And gt8.Enabled = False And d8.Enabled = False
ip9.Enabled = False And gt9.Enabled = False And d9.Enabled = False
ip10.Enabled = False And gt10.Enabled = False And d10.Enabled = False
End If
If s4.Caption = "Create" And s4.Value = True Then
p4.Visible = True
s4.Caption = "Select"
End If
If s4.Value = False And ip4.Text = "" Then
s4.Caption = "Create" And p4.Visible = False
End If
End Sub

Private Sub s5_Click()
If s5.Value = True Then
ip1.Enabled = False And gt1(1).Enabled = False And d1.Enabled = False
ip2.Enabled = False And gt2.Enabled = False And d2.Enabled = False
ip3.Enabled = False And gt3.Enabled = False And d3.Enabled = False
ip4.Enabled = False And gt4.Enabled = False And d4.Enabled = False
ip5.Enabled = True And gt5.Enabled = True And d5.Enabled = True
ip6.Enabled = False And gt6.Enabled = False And d6.Enabled = False
ip7.Enabled = False And gt7.Enabled = False And d7.Enabled = False
ip8.Enabled = False And gt8.Enabled = False And d8.Enabled = False
ip9.Enabled = False And gt9.Enabled = False And d9.Enabled = False
ip10.Enabled = False And gt10.Enabled = False And d10.Enabled = False
End If
If s5.Caption = "Create" And s5.Value = True Then
p5.Visible = True
s5.Caption = "Select"
End If
If s5.Value = False And ip5.Text = "" Then
s5.Caption = "Create" And p5.Visible = False
End If
End Sub

Private Sub s6_Click()
If s6.Value = True Then
ip1.Enabled = False And gt1(1).Enabled = False And d1.Enabled = False
ip2.Enabled = False And gt2.Enabled = False And d2.Enabled = False
ip3.Enabled = False And gt3.Enabled = False And d3.Enabled = False
ip4.Enabled = False And gt4.Enabled = False And d4.Enabled = False
ip5.Enabled = False And gt5.Enabled = False And d5.Enabled = False
ip6.Enabled = True And gt6.Enabled = True And d6.Enabled = True
ip7.Enabled = False And gt7.Enabled = False And d7.Enabled = False
ip8.Enabled = False And gt8.Enabled = False And d8.Enabled = False
ip9.Enabled = False And gt9.Enabled = False And d9.Enabled = False
ip10.Enabled = False And gt10.Enabled = False And d10.Enabled = False
End If
If s6.Caption = "Create" And s6.Value = True Then
p6.Visible = True
s6.Caption = "Select"
End If
If s6.Value = False And ip6.Text = "" Then
s6.Caption = "Create" And p6.Visible = False
End If
End Sub

Private Sub s7_Click()
If s7.Value = True Then
ip1.Enabled = False And gt1(1).Enabled = False And d1.Enabled = False
ip2.Enabled = False And gt2.Enabled = False And d2.Enabled = False
ip3.Enabled = False And gt3.Enabled = False And d3.Enabled = False
ip4.Enabled = False And gt4.Enabled = False And d4.Enabled = False
ip5.Enabled = False And gt5.Enabled = False And d5.Enabled = False
ip6.Enabled = False And gt6.Enabled = False And d6.Enabled = False
ip7.Enabled = True And gt7.Enabled = True And d7.Enabled = True
ip8.Enabled = False And gt8.Enabled = False And d8.Enabled = False
ip9.Enabled = False And gt9.Enabled = False And d9.Enabled = False
ip10.Enabled = False And gt10.Enabled = False And d10.Enabled = False
End If
If s7.Caption = "Create" And s7.Value = True Then
p7.Visible = True
s7.Caption = "Select"
End If
If s7.Value = False And ip7.Text = "" Then
s7.Caption = "Create" And p7.Visible = False
End If
End Sub

Private Sub s8_Click()
If s8.Value = True Then
ip1.Enabled = False And gt1(1).Enabled = False And d1.Enabled = False
ip2.Enabled = False And gt2.Enabled = False And d2.Enabled = False
ip3.Enabled = False And gt3.Enabled = False And d3.Enabled = False
ip4.Enabled = False And gt4.Enabled = False And d4.Enabled = False
ip5.Enabled = False And gt5.Enabled = False And d5.Enabled = False
ip6.Enabled = False And gt6.Enabled = False And d6.Enabled = False
ip7.Enabled = False And gt7.Enabled = False And d7.Enabled = False
ip8.Enabled = True And gt8.Enabled = True And d8.Enabled = True
ip9.Enabled = False And gt9.Enabled = False And d9.Enabled = False
ip10.Enabled = False And gt10.Enabled = False And d10.Enabled = False
End If
If s8.Caption = "Create" And s8.Value = True Then
p8.Visible = True
s8.Caption = "Select"
End If
If s8.Value = False And ip8.Text = "" Then
s8.Caption = "Create" And p8.Visible = False
End If
End Sub

Private Sub s9_Click()
If s9.Value = True Then
ip1.Enabled = False And gt1(1).Enabled = False And d1.Enabled = False
ip2.Enabled = False And gt2.Enabled = False And d2.Enabled = False
ip3.Enabled = False And gt3.Enabled = False And d3.Enabled = False
ip4.Enabled = False And gt4.Enabled = False And d4.Enabled = False
ip5.Enabled = False And gt5.Enabled = False And d5.Enabled = False
ip6.Enabled = False And gt6.Enabled = False And d6.Enabled = False
ip7.Enabled = False And gt7.Enabled = False And d7.Enabled = False
ip8.Enabled = False And gt8.Enabled = False And d8.Enabled = False
ip9.Enabled = True And gt9.Enabled = True And d9.Enabled = True
ip10.Enabled = False And gt10.Enabled = False And d10.Enabled = False
End If
If s9.Caption = "Create" And s9.Value = True Then
p9.Visible = True
s9.Caption = "Select"
End If
If s9.Value = False And ip9.Text = "" Then
s9.Caption = "Create" And p9.Visible = False
End If
End Sub

CornEmpire Board Administrator
<A HREF="http://www.geocities.com/thecornmaster/" target="_new">http://www.geocities.com/thecornmaster/</A>
__________________
~Complex Solutions to Simple Problems~
http://www.cornempire.com
Reply With Quote
  #2  
Old 10-24-2000, 02:14 PM
BillSoo's Avatar
BillSooAny way to make this easier? BillSoo is offline
Code Meister

Retired Moderator
* Guru *
 
Join Date: Aug 2000
Location: Vancouver, BC, Canada
Posts: 10,441
Default Re: Any way to make this easier?

In the line

ip2.Enabled = False And gt2.Enabled = False And d2.Enabled = False

I think you meant

ip2.Enabled = False: gt2.Enabled = False :d2.Enabled = False



"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder
__________________
"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder
Reply With Quote
  #3  
Old 10-24-2000, 02:32 PM
PWNettleAny way to make this easier? PWNettle is offline
Verbose Coder

Retired Moderator
* Guru *
 
Join Date: Dec 1999
Location: Phoenix, Arizona
Posts: 3,011
Default Re: Any way to make this easier?

You might want to look into control arrays.

Paul


Reply With Quote
  #4  
Old 10-24-2000, 03:11 PM
Flamelord
Guest
 
Posts: n/a
Default Re: Any way to make this easier?

I agree with Paul, control arrays would solve your problem, but it seems that a little Form redesign is in order. What does the form do? Why do you need so many controls? What are the options for? Could you attach the form?

Reply With Quote
  #5  
Old 10-24-2000, 03:26 PM
CornMaster's Avatar
CornMaster CornMaster is offline
Contributor
 
Join Date: Aug 2000
Location: St. John's, Newfoundland
Posts: 655
Default Re: Any way to make this easier?

Well luckly I'm not using that code anymore. Found another way to do it but I still got a question. Any way to make all option buttons (or anything for that matter) visible = true or visible = false when one is clicked with out having the same kind of code from above?

And how do you make a varaible (x for example) availible to all forms? In a module?

CornEmpire Board Administrator
<A HREF="http://www.geocities.com/thecornmaster/" target="_new">http://www.geocities.com/thecornmaster/</A>
__________________
~Complex Solutions to Simple Problems~
http://www.cornempire.com
Reply With Quote
  #6  
Old 10-24-2000, 03:55 PM
MarkG
Guest
 
Posts: n/a
Default Re: Any way to make this easier?

First, assign the same tag to the controls that are related. Then write a class module in which you pass the specific tag that will hide, disable, enable, change color, change backstyle, etc. the controls that have that tag. For example:

Public Property Let Tag(strTag As String)
mstrTag = strTag
End Property
Public Property Get Tag() As String
Tag = mstrTag
End Property

Public Sub ClearOpt(objObject As Object)

'Clear all option buttons containing the specified tag value
'-----------------------------------------------------------
For Each ctlControl In objObject.Controls
If ctlControl.Tag = Tag Then
ctlControl.Value = False
End If
Next ctlControl

End Sub




Reply With Quote
  #7  
Old 10-24-2000, 03:59 PM
PWNettleAny way to make this easier? PWNettle is offline
Verbose Coder

Retired Moderator
* Guru *
 
Join Date: Dec 1999
Location: Phoenix, Arizona
Posts: 3,011
Default Re: Any way to make this easier?

If you use control arrays you can easily modify a lot of controls in a hurry with a loop.

Instead of ctr1, ctr2, ctr3, etc. you'd have indexed controls like ctr(0), ctr(1), ctr(2), ctr(3), etc which you can loop against like:
<PRE> For intIndex = 0 To ctr.Count - 1
ctr(intIndex).Enabled = Not ctr(intIndex).Enabled
Next intIndex</PRE>
If you have a lot of similar controls this can save you volumes of code. Control arrays work a lot like regular variable arrays except you get the hand .Count property with them. An easy way to create a control array is to copy a control on a form then immediately paste on the same form...VB prompts you about creating a control array...just say 'Yes'!

If you want a variable to be available to all your forms you can declare it as Public (ex: Public intX As Integer) inside a normal (.BAS) module.

Paul


Reply With Quote
  #8  
Old 10-24-2000, 04:09 PM
BillSoo's Avatar
BillSooAny way to make this easier? BillSoo is offline
Code Meister

Retired Moderator
* Guru *
 
Join Date: Aug 2000
Location: Vancouver, BC, Canada
Posts: 10,441
Default Re: Any way to make this easier?

If you put these controls into a frame or picturebox, you can make that container visible/invisible instead of the individual controls.

"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder
__________________
"I have a plan so cunning you could put a tail on it and call it a weasel!" - Edmund Blackadder
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Any way to make this easier?
Any way to make this easier?
Any way to make this easier? Any way to make this easier?
Any way to make this easier?
Any way to make this easier?
Any way to make this easier? Any way to make this easier? Any way to make this easier? Any way to make this easier? Any way to make this easier? Any way to make this easier? Any way to make this easier?
Any way to make this easier?
Any way to make this easier?
 
Any way to make this easier?
Any way to make this easier?
 
-->