|
-
Oct 29th, 2009, 11:50 AM
#1
Thread Starter
Junior Member
Help me with radios
I have 3 radios and 1 ok command.
I dont want the program to progress if either of the 3 remain not selected.
What do I do?I mean the same form should load incase one clicks ok.
-
Oct 29th, 2009, 11:51 AM
#2
Thread Starter
Junior Member
Re: Help me with radios
I mean the same form should load incase 1 clicks ok without clicking any radio.
-
Oct 29th, 2009, 12:24 PM
#3
Re: Help me with radios
If you want to check the state of 3 radio buttons from your code, you can create a control array.
Something like this.
Code:
Private Sub Command1_Click()
For index = 0 To Option1.Count - 1 'Count all the buttons on the screen
If Option1(index).Value = True Then 'Check State of the button
Form2.Show 'Show form.
End If
Next
End Sub
The only issue I see with this approach is that when the form loads, one of the buttons is bound to be selected. I am sure, there is a way to avoid that, but I am unable to recall it.
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Oct 29th, 2009, 12:32 PM
#4
Re: Help me with radios
 Originally Posted by abhijit
The only issue I see with this approach is that when the form loads, one of the buttons is bound to be selected. I am sure, there is a way to avoid that, but I am unable to recall it.
If a TabIndex of 0 is place on another control (like a command button for instance), then none of the option buttons will be selected by default.
-
Oct 29th, 2009, 12:33 PM
#5
Re: Help me with radios
Code:
'~~> In Form Load
For Index = 0 To Option1.Count - 1 'Count all the buttons on the screen
Option1(Index).Value = False
Next
Private Sub Command1_Click()
For Index = 0 To Option1.Count - 1 'Count all the buttons on the screen
If Option1(Index).Value = True Then 'Check State of the button
Form2.Show 'Show form.
Exit Sub '<~~ A slight amendment
End If
Next
End Sub
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Oct 29th, 2009, 12:35 PM
#6
Re: Help me with radios
 Originally Posted by Hack
If a TabIndex of 0 is place on another control (like a command button for instance), then none of the option buttons will be selected by default.
 Originally Posted by koolsid
Code:
'~~> In Form Load
For Index = 0 To Option1.Count - 1 'Count all the buttons on the screen
Option1(Index).Value = False
Next
Private Sub Command1_Click()
For Index = 0 To Option1.Count - 1 'Count all the buttons on the screen
If Option1(Index).Value = True Then 'Check State of the button
Form2.Show 'Show form.
Exit Sub '<~~ A slight amendment
End If
Next
End Sub
Thanks!
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Oct 29th, 2009, 06:35 PM
#7
Re: Help me with radios
 Originally Posted by casio2000123
I have 3 radios and 1 ok command.
I dont want the program to progress if either of the 3 remain not selected.
What do I do?I mean the same form should load incase one clicks ok.
Radio = Command = Radio. Is that correct?
-
Oct 29th, 2009, 11:39 PM
#8
Re: Help me with radios
Code:
Private Sub Command1_Click()
For i = Option1.LBound To Option1.UBound
If Option1(i).Value = True Then
Form2.Show
Exit For
End If
Next
End Sub
Private Sub Form_Load()
For i = Option1.LBound To Option1.UBound
Option1(i).Value = False
Next
End Sub
-
Oct 29th, 2009, 11:50 PM
#9
Thread Starter
Junior Member
Re: Help me with radios
Sorry people for replying so late into this(I was stunned by the fact that I managed a soluion! )but I cracked this using
if .............then
if op1=true then
something
elseif opt2=true the
something
elseif opt3=true then
something
else
again load form1
end if
It did not need loops,see!
-
Oct 30th, 2009, 01:34 AM
#10
Re: Help me with radios
Sorry people for replying so late into this(I was stunned by the fact that I managed a soluion!)but I cracked this using
if .............then
if op1=true then
something
elseif opt2=true the
something
elseif opt3=true then
something
else
again load form1
end if
It did not need loops,see!
If you are using an array of Option1 (like Option1(0), Option1(1), etc...), then all the codes posted by others will be helpful... 
They had given these codes, thinking that you are using an array of controls... 
So, casio2000123, please try to give more details of the problem rather than giving three lines... I mean, you have to describe it...
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
Oct 30th, 2009, 08:04 AM
#11
Re: Help me with radios
 Originally Posted by Code Doc
Radio = Command = Radio. Is that correct? 
I am not sure, what you meant CD, but Radio = Option
Everything that has a computer in will fail. Everything in your life, from a watch to a car to, you know, a radio, to an iPhone, it will fail if it has a computer in it. They should kill the people who made those things.- 'Woz'
save a blobFileStreamDataTable To Text Filemy blog
-
Oct 30th, 2009, 01:56 PM
#12
Hyperactive Member
Re: Help me with radios
Regarding your solution quoted below, it's not necessary to reload the form; it's already there. Just check the radio buttons as you have done already, then End If. That's it. Don't even include the Else clause. That way if none of them are selected it will simply be done with the procedure and not do anything.
 Originally Posted by casio2000123
Sorry people for replying so late into this(I was stunned by the fact that I managed a soluion!   )but I cracked this using
if .............then
if op1=true then
something
elseif opt2=true the
something
elseif opt3=true then
something
else
again load form1
end if
It did not need loops,see!
-
Oct 30th, 2009, 09:10 PM
#13
PowerPoster
Re: Help me with radios
Code:
If Option1.Value = True And Option2.Value = True And Option3.Value = True then
...........
I have a huge free products range, of computer software in which you can download using any kind of 64-Bit Web Browser. Also there is coming a Social Networking section that I am making on my Website...
|Ambra Productions Inc. | The Black Sun Society | The Black Shield | Ambra College | Church of the Black Sun | Ambra Productions Inc's Homepage | Boomtick Venues: Ambar Nightclub, Jack Rabbit Slim's, Villa Nightclub and Lucy's Love Shack | Pasta Ambra | Fish Feast Company | Wallet Wizard | Ambrose Liquor | Ambar Tavern | Ambra University | Ambra Cheese |
Do you wish to do unpaid work for me??? If so, the PM me on this Forum, and then we can get to work, programming for the future of computers go by the name of ThEiMp. This is my ghost writers name. Also my nickname, means that I am: The Imperial of the Technology Industry, so then to make it really short, I just then wrote: The Imp, which is where I get the nickname from...
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
|