How to get a radio button out of a group, declaring a universal variable


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: How to get a radio button out of a group, declaring a universal variable

  1. #1
    XerosAqua Guest

    How to get a radio button out of a group, declaring a universal variable


    Well the code i was given works pretty well, with a few modifications ""
    Private Sub Command1_Click()


    Dim verb As String 'Create new variables to hold
    Dim Verb1 As String 'creates place for first person
    Dim Verb2 As String 'secound
    Dim Verb3 As String 'third
    Dim verb4 As String '
    Dim verb5 As String
    Dim verb6 As String

    Dim letter As String * 1 'the text and the last letter
    Dim end As string
    Dim end1 As String 'as well as the ending.
    Dim end2 As String
    Dim end3 As String
    Dim end4 As String
    Dim end5 As String
    Dim end5 As String
    Dim end6 As String

    verb = txtLAT.Text 'Fill the text variable.
    letter = Right(verb, 1) 'Get the last letter.

    If letter = "a" Or _
    letter = "e" Or _
    letter = "i" Or _
    letter = "o" Or _
    letter = "u" Then 'Check to see if the last letter
    'is a vowel, if so...
    verb = verb & end 'add the ending
    Verb1 = verb & end1
    Verb2 = verb & end2
    Verb3 = verb & end3
    verb4 = verb & end4
    verb5 = verb & end5
    verb6 = verb & end6
    End If


    Ist.Caption = verb1
    Snd.Caption = verb2
    Erd.Caption = verb3
    Fth.Caption = verb4
    Sth.Caption = verb5
    SXth.Caption = verb6



    End Sub
    ""
    I havent tried it yet, but i think it will work
    But NOTICe that i havent defined the endings
    and they are defined within this sub state ment
    which is a problem
    the form for this is a textbox for entering the verb
    a button for doing the operation which triggers the above
    and a HUGE multitude of radio buttons
    i knew that you could group a set of radio buttons
    by creating the frame first
    then the buttons, but some frames may conflict with others
    (its impossible to have a subjunctive passive) etc..

    THey are arranged by several groups
    but to be able to dissable one group while another is active
    i put a radio button in each group to enable that group,
    such as (i dont know where id put it)
    if radSUBJENABLE 'enables subjumctive dissables passive voice
    radPASSVEN.Visible = false
    ,
    but the actual problem is the fact that i put the button within the same
    group as the group that needs to be the control(meaning that if i clicked
    "enable past tense" i could only click enable
    past tense and not click any of the radio buttons it controls
    So HERE IS THE MAIN QUESTION
    how do i make 1 radio button control the visible factor of a group of buttons
    and other groups
    , and how do you make a variable exists throughout a program not just in
    the sub?

  2. #2
    Matt Wyant Guest

    Re: How to get a radio button out of a group, declaring a universal variable

    I'm having a little trouble understanding your problem so I will try to
    address it as well as I can.

    Question #1: How to control the visible factor of a group of buttons and
    other groups.

    If you are using frames, the operation is fairly simple. When the
    visible property of a frame changes, so does the visible property of all the
    controls contained within. You would probably be better of using the enabled
    property, however, because then your users would more accurately understand
    the effects of their actions.

    Question #2: How do you make a variable exist throughout a program.

    When you declare a variable using 'Dim' it is automatically set as
    private, which means it is only 'visible' in the portion of code it was
    declared in. So if you declare within a sub, only that sub, and the code
    within that sub, can 'see' the variable. This concept is called Scope.
    There are several ways of making a variable visible to more of your
    code, and the times to use the different methods depend on how your program
    is laid out.
    If you want the variable's scope to extend only to the current
    module (the code in one form, or in one module, or in one class) simply
    declare it BEFORE any subroutines are written E.g.:

    <<<Code for frmMain>>>
    Dim verb1 as String

    Private Sub sub1()
    Dim verb2 as String
    ...
    verb1 = some stuff
    ...
    End Sub

    Private Sub sub2()
    Dim verb3 as String
    ...
    verb1 = more stuff
    ...
    End Sub
    <<<End Code>>>

    In this example the variable verb1 can be seen by both subs because they are
    contained within the module in which the variable was declared. Whereas
    verb2 can only be seen by Sub1 and verb3 by sub2.

    If you want your variable's (verb1) scope to extend to all parts of
    your program (frmNew and modFunctions), instead of 'Dim' use 'Public', and
    in other modules (frmNew and modFunctions) refer to the variable as
    frmMain.verb1 and in the declared module (frmMain) you can refer to it as
    frmMain.verb1 or just verb1

    Hope this helps.

    Matt Wyant
    MDWyant@SRPnet.com


    "XerosAqua" <XerosAqua@hotmail.com> wrote in message
    news:3a18b202$1@news.devx.com...
    >
    > Well the code i was given works pretty well, with a few modifications ""
    > Private Sub Command1_Click()
    >
    >
    > Dim verb As String 'Create new variables to hold
    > Dim Verb1 As String 'creates place for first person
    > Dim Verb2 As String 'secound
    > Dim Verb3 As String 'third
    > Dim verb4 As String '
    > Dim verb5 As String
    > Dim verb6 As String
    >
    > Dim letter As String * 1 'the text and the last letter
    > Dim end As string
    > Dim end1 As String 'as well as the ending.
    > Dim end2 As String
    > Dim end3 As String
    > Dim end4 As String
    > Dim end5 As String
    > Dim end5 As String
    > Dim end6 As String
    >
    > verb = txtLAT.Text 'Fill the text variable.
    > letter = Right(verb, 1) 'Get the last letter.
    >
    > If letter = "a" Or _
    > letter = "e" Or _
    > letter = "i" Or _
    > letter = "o" Or _
    > letter = "u" Then 'Check to see if the last letter
    > 'is a vowel, if so...
    > verb = verb & end 'add the ending
    > Verb1 = verb & end1
    > Verb2 = verb & end2
    > Verb3 = verb & end3
    > verb4 = verb & end4
    > verb5 = verb & end5
    > verb6 = verb & end6
    > End If
    >
    >
    > Ist.Caption = verb1
    > Snd.Caption = verb2
    > Erd.Caption = verb3
    > Fth.Caption = verb4
    > Sth.Caption = verb5
    > SXth.Caption = verb6
    >
    >
    >
    > End Sub
    > ""
    > I havent tried it yet, but i think it will work
    > But NOTICe that i havent defined the endings
    > and they are defined within this sub state ment
    > which is a problem
    > the form for this is a textbox for entering the verb
    > a button for doing the operation which triggers the above
    > and a HUGE multitude of radio buttons
    > i knew that you could group a set of radio buttons
    > by creating the frame first
    > then the buttons, but some frames may conflict with others
    > (its impossible to have a subjunctive passive) etc..
    >
    > THey are arranged by several groups
    > but to be able to dissable one group while another is active
    > i put a radio button in each group to enable that group,
    > such as (i dont know where id put it)
    > if radSUBJENABLE 'enables subjumctive dissables passive voice
    > radPASSVEN.Visible = false
    > ,
    > but the actual problem is the fact that i put the button within the same
    > group as the group that needs to be the control(meaning that if i clicked
    > "enable past tense" i could only click enable
    > past tense and not click any of the radio buttons it controls
    > So HERE IS THE MAIN QUESTION
    > how do i make 1 radio button control the visible factor of a group of

    buttons
    > and other groups
    > , and how do you make a variable exists throughout a program not just in
    > the sub?




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center