Results 1 to 13 of 13

Thread: Help me with radios

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2009
    Posts
    25

    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.

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Oct 2009
    Posts
    25

    Re: Help me with radios

    I mean the same form should load incase 1 clicks ok without clicking any radio.

  3. #3
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    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

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Help me with radios

    Quote Originally Posted by abhijit View Post
    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.

  5. #5
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    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

  6. #6
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Re: Help me with radios

    Quote Originally Posted by Hack View Post
    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.
    Quote Originally Posted by koolsid View Post
    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

  7. #7
    PowerPoster Code Doc's Avatar
    Join Date
    Mar 2007
    Location
    Omaha, Nebraska
    Posts
    2,354

    Re: Help me with radios

    Quote Originally Posted by casio2000123 View Post
    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?
    Doctor Ed

  8. #8
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    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
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  9. #9

    Thread Starter
    Junior Member
    Join Date
    Oct 2009
    Posts
    25

    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!

  10. #10
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    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,...

  11. #11
    PowerPoster abhijit's Avatar
    Join Date
    Jun 1999
    Location
    Chit Chat Forum.
    Posts
    3,228

    Re: Help me with radios

    Quote Originally Posted by Code Doc View Post
    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

  12. #12
    Hyperactive Member danecook21's Avatar
    Join Date
    Feb 2008
    Location
    NC, USA
    Posts
    501

    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.

    Quote Originally Posted by casio2000123 View Post
    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!

  13. #13
    PowerPoster ThEiMp's Avatar
    Join Date
    Dec 2007
    Location
    Take The PCI Bus Across To The CPU!!
    Posts
    3,948

    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
  •  



Click Here to Expand Forum to Full Width