vb6 frames

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gttby
    New Member
    • Feb 2007
    • 13

    vb6 frames

    Hi guys... I am really stuck... How do I perform a selection process using the if statement to carry out a certain process only if one of the selection options in a frame are true.... Please help I have now spent 4 hours on this without any luck.....
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Hi don't know what the name of your option group is so we will work with option1, option2 etc.

    Code:
    If Option1 Then
       'blah blah blah
    ElseIf Option2 Then
       'blah blah blah
    ElseIf Option2 Then
       'blah blah blah
    End If

    Comment

    • willakawill
      Top Contributor
      • Oct 2006
      • 1646

      #3
      By the way. Another way of using these values in code is like this:

      Code:
      txtBox1.Visible = Option1
      txtBox2.Visible = Option2
      txtBox2.Visible = Option3
      I am sure you get the picture.

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by gttby
        Hi guys... I am really stuck... How do I perform a selection process using the if statement to carry out a certain process only if one of the selection options in a frame are true.... Please help I have now spent 4 hours on this without any luck.....
        You may be confusing it with VBA, where the frame itself returns a value based on the selection within it. I'm almost certain VB6 doesn't do that.

        You need to interrogate the individual controls. For example, if you have a bunch of option buttons in the frame, then you need to do something like looping through the option buttons (which are hopefully in an array) and see which one has Value = True.

        It might make more sense to set a form-level (or global) variable each time one of the option buttons is selected, then just check that value when you want to know the result.

        Oh rats! Willakawill beat me to it again. :)

        Comment

        • gttby
          New Member
          • Feb 2007
          • 13

          #5
          Originally posted by willakawill
          Hi don't know what the name of your option group is so we will work with option1, option2 etc.

          Code:
          If Option1 Then
             'blah blah blah
          ElseIf Option2 Then
             'blah blah blah
          ElseIf Option2 Then
             'blah blah blah
          End If
          Many thanks but where do i Place this code is it on frame click or what I am a bit confused...

          Comment

          • gttby
            New Member
            • Feb 2007
            • 13

            #6
            Originally posted by Killer42
            You may be confusing it with VBA, where the frame itself returns a value based on the selection within it. I'm almost certain VB6 doesn't do that.

            You need to interrogate the individual controls. For example, if you have a bunch of option buttons in the frame, then you need to do something like looping through the option buttons (which are hopefully in an array) and see which one has Value = True.

            It might make more sense to set a form-level (or global) variable each time one of the option buttons is selected, then just check that value when you want to know the result.

            Oh rats! Willakawill beat me to it again. :)
            Many thanks I think ur Idea is good but how do i loop around the options to see which one is selected b4 assingning a value to global variable...sorr y if its too much to ask

            Comment

            • Killer42
              Recognized Expert Expert
              • Oct 2006
              • 8429

              #7
              Originally posted by gttby
              Many thanks but where do i Place this code is it on frame click or what I am a bit confused...
              You do this code at the point where you want to know which option is currently selected.

              If it is supposed to happen as soon as the user clicks, then it would go in the appropriate event of the option button (array, I hope). Probably the Click event.

              Comment

              • gttby
                New Member
                • Feb 2007
                • 13

                #8
                Originally posted by Killer42
                You do this code at the point where you want to know which option is currently selected.

                If it is supposed to happen as soon as the user clicks, then it would go in the appropriate event of the option button (array, I hope). Probably the Click event.
                Many thanks killer42... I will crack on it now......

                Comment

                • willakawill
                  Top Contributor
                  • Oct 2006
                  • 1646

                  #9
                  Originally posted by gttby
                  Many thanks but where do i Place this code is it on frame click or what I am a bit confused...
                  Yup, just as Killer says, you don't get run by your code, you run your code the way that you want it. Look at the values exactly when it works for you to do so.

                  Comment

                  • gttby
                    New Member
                    • Feb 2007
                    • 13

                    #10
                    Originally posted by willakawill
                    Yup, just as Killer says, you don't get run by your code, you run your code the way that you want it. Look at the values exactly when it works for you to do so.
                    Many thanks Willakawill and Killer42 the code is now working fine ... Thanks Guys......

                    Comment

                    Working...