+ Reply to Thread
Results 1 to 2 of 2

Why wont this code work?

  1. #1
    Mark Stephens
    Guest

    Why wont this code work?

    I'm trying to get the effect of a push button radio so only one at oce will
    be pushed (ie all the others pop out if one is pressed).

    Strange thing is, if I go into design mode and run the code from within VB
    by say clicking on toggle button 1 and then step through it, it works!

    Maybe there's an easy way of doing this (grouping them) it seems to be the
    way most people would want to use them (like option buttons?). Any help much
    appreciated; stuff like this sucks up your time and attention so you can't
    do what you need to.

    Private bBlockEvent As Boolean

    Private Sub ToggleButton1_Click()

    If bBlockEvent = True Then Exit Sub

    If ToggleButton2 = True Then
    bBlockEvent = True
    ToggleButton2 = False
    End If
    If ToggleButton3 = True Then
    bBlockEvent = True
    ToggleButton3 = False
    End If
    If ToggleButton4 = True Then
    bBlockEvent = True
    ToggleButton4 = False
    End If
    If ToggleButton5 = True Then
    bBlockEvent = True
    ToggleButton5 = False
    End If
    If ToggleButton6 = True Then
    bBlockEvent = True
    ToggleButton6 = False
    End If

    End Sub

    Private Sub ToggleButton2_Click()

    If bBlockEvent = True Then Exit Sub

    If ToggleButton1 = True Then
    bBlockEvent = True
    ToggleButton1 = False
    End If
    If ToggleButton3 = True Then
    bBlockEvent = True
    ToggleButton3 = False
    End If
    If ToggleButton4 = True Then
    bBlockEvent = True
    ToggleButton4 = False
    End If
    If ToggleButton5 = True Then
    bBlockEvent = True
    ToggleButton5 = False
    End If
    If ToggleButton6 = True Then
    bBlockEvent = True
    ToggleButton6 = False
    End If

    End Sub

    Private Sub ToggleButton3_Click()

    If bBlockEvent = True Then Exit Sub

    If ToggleButton1 = True Then
    bBlockEvent = True
    ToggleButton1 = False
    End If
    If ToggleButton2 = True Then
    bBlockEvent = True
    ToggleButton2 = False
    End If
    If ToggleButton4 = True Then
    bBlockEvent = True
    ToggleButton4 = False
    End If
    If ToggleButton5 = True Then
    bBlockEvent = True
    ToggleButton5 = False
    End If
    If ToggleButton6 = True Then
    bBlockEvent = True
    ToggleButton6 = False
    End If

    End Sub

    Private Sub ToggleButton4_Click()

    If bBlockEvent = True Then Exit Sub

    If ToggleButton1 = True Then
    bBlockEvent = True
    ToggleButton1 = False
    End If
    If ToggleButton2 = True Then
    bBlockEvent = True
    ToggleButton2 = False
    End If
    If ToggleButton3 = True Then
    bBlockEvent = True
    ToggleButton3 = False
    End If
    If ToggleButton5 = True Then
    bBlockEvent = True
    ToggleButton5 = False
    End If
    If ToggleButton6 = True Then
    bBlockEvent = True
    ToggleButton6 = False
    End If

    End Sub

    Private Sub ToggleButton5_Click()

    If bBlockEvent = True Then Exit Sub

    If ToggleButton1 = True Then
    bBlockEvent = True
    ToggleButton1 = False
    End If
    If ToggleButton2 = True Then
    bBlockEvent = True
    ToggleButton2 = False
    End If
    If ToggleButton3 = True Then
    bBlockEvent = True
    ToggleButton3 = False
    End If
    If ToggleButton4 = True Then
    bBlockEvent = True
    ToggleButton4 = False
    End If
    If ToggleButton6 = True Then
    bBlockEvent = True
    ToggleButton6 = False
    End If

    End Sub

    Private Sub ToggleButton6_Click()

    If bBlockEvent = True Then Exit Sub

    If ToggleButton1 = True Then
    bBlockEvent = True
    ToggleButton1 = False
    End If
    If ToggleButton2 = True Then
    bBlockEvent = True
    ToggleButton2 = False
    End If
    If ToggleButton3 = True Then
    bBlockEvent = True
    ToggleButton3 = False
    End If
    If ToggleButton4 = True Then
    bBlockEvent = True
    ToggleButton4 = False
    End If
    If ToggleButton5 = True Then
    bBlockEvent = True
    ToggleButton5 = False
    End If
    End Sub




  2. #2
    Bob Phillips
    Guest

    Re: Why wont this code work?

    Why not use optionbuttons, they work that way by default.

    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "Mark Stephens" <mark@sentryi.com> wrote in message
    news:d50ds3$tge$1@mawar.singnet.com.sg...
    > I'm trying to get the effect of a push button radio so only one at oce

    will
    > be pushed (ie all the others pop out if one is pressed).
    >
    > Strange thing is, if I go into design mode and run the code from within VB
    > by say clicking on toggle button 1 and then step through it, it works!
    >
    > Maybe there's an easy way of doing this (grouping them) it seems to be the
    > way most people would want to use them (like option buttons?). Any help

    much
    > appreciated; stuff like this sucks up your time and attention so you can't
    > do what you need to.
    >
    > Private bBlockEvent As Boolean
    >
    > Private Sub ToggleButton1_Click()
    >
    > If bBlockEvent = True Then Exit Sub
    >
    > If ToggleButton2 = True Then
    > bBlockEvent = True
    > ToggleButton2 = False
    > End If
    > If ToggleButton3 = True Then
    > bBlockEvent = True
    > ToggleButton3 = False
    > End If
    > If ToggleButton4 = True Then
    > bBlockEvent = True
    > ToggleButton4 = False
    > End If
    > If ToggleButton5 = True Then
    > bBlockEvent = True
    > ToggleButton5 = False
    > End If
    > If ToggleButton6 = True Then
    > bBlockEvent = True
    > ToggleButton6 = False
    > End If
    >
    > End Sub
    >
    > Private Sub ToggleButton2_Click()
    >
    > If bBlockEvent = True Then Exit Sub
    >
    > If ToggleButton1 = True Then
    > bBlockEvent = True
    > ToggleButton1 = False
    > End If
    > If ToggleButton3 = True Then
    > bBlockEvent = True
    > ToggleButton3 = False
    > End If
    > If ToggleButton4 = True Then
    > bBlockEvent = True
    > ToggleButton4 = False
    > End If
    > If ToggleButton5 = True Then
    > bBlockEvent = True
    > ToggleButton5 = False
    > End If
    > If ToggleButton6 = True Then
    > bBlockEvent = True
    > ToggleButton6 = False
    > End If
    >
    > End Sub
    >
    > Private Sub ToggleButton3_Click()
    >
    > If bBlockEvent = True Then Exit Sub
    >
    > If ToggleButton1 = True Then
    > bBlockEvent = True
    > ToggleButton1 = False
    > End If
    > If ToggleButton2 = True Then
    > bBlockEvent = True
    > ToggleButton2 = False
    > End If
    > If ToggleButton4 = True Then
    > bBlockEvent = True
    > ToggleButton4 = False
    > End If
    > If ToggleButton5 = True Then
    > bBlockEvent = True
    > ToggleButton5 = False
    > End If
    > If ToggleButton6 = True Then
    > bBlockEvent = True
    > ToggleButton6 = False
    > End If
    >
    > End Sub
    >
    > Private Sub ToggleButton4_Click()
    >
    > If bBlockEvent = True Then Exit Sub
    >
    > If ToggleButton1 = True Then
    > bBlockEvent = True
    > ToggleButton1 = False
    > End If
    > If ToggleButton2 = True Then
    > bBlockEvent = True
    > ToggleButton2 = False
    > End If
    > If ToggleButton3 = True Then
    > bBlockEvent = True
    > ToggleButton3 = False
    > End If
    > If ToggleButton5 = True Then
    > bBlockEvent = True
    > ToggleButton5 = False
    > End If
    > If ToggleButton6 = True Then
    > bBlockEvent = True
    > ToggleButton6 = False
    > End If
    >
    > End Sub
    >
    > Private Sub ToggleButton5_Click()
    >
    > If bBlockEvent = True Then Exit Sub
    >
    > If ToggleButton1 = True Then
    > bBlockEvent = True
    > ToggleButton1 = False
    > End If
    > If ToggleButton2 = True Then
    > bBlockEvent = True
    > ToggleButton2 = False
    > End If
    > If ToggleButton3 = True Then
    > bBlockEvent = True
    > ToggleButton3 = False
    > End If
    > If ToggleButton4 = True Then
    > bBlockEvent = True
    > ToggleButton4 = False
    > End If
    > If ToggleButton6 = True Then
    > bBlockEvent = True
    > ToggleButton6 = False
    > End If
    >
    > End Sub
    >
    > Private Sub ToggleButton6_Click()
    >
    > If bBlockEvent = True Then Exit Sub
    >
    > If ToggleButton1 = True Then
    > bBlockEvent = True
    > ToggleButton1 = False
    > End If
    > If ToggleButton2 = True Then
    > bBlockEvent = True
    > ToggleButton2 = False
    > End If
    > If ToggleButton3 = True Then
    > bBlockEvent = True
    > ToggleButton3 = False
    > End If
    > If ToggleButton4 = True Then
    > bBlockEvent = True
    > ToggleButton4 = False
    > End If
    > If ToggleButton5 = True Then
    > bBlockEvent = True
    > ToggleButton5 = False
    > End If
    > End Sub
    >
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1