473,770 Members | 2,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Turning a radio button into a toggle button

I would like to create a toggle button, so I chose a radio and set its
apperance to button. Is seems my method always makes this .checked = false.
Can somebody help me to see the error in my ways? I'm guessing that I just
need an event that triggers before it actually changes the value of the
button.

Private Sub radSound_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles radSound.Click
If radSound.Checke d = True Then radSound.Checke d = False Else
radSound = True
End Sub

--
Jeff Ciaccio
Physics and AP Physics Teacher
Sprayberry High School; Marietta, GA
Blog: http://sprayberry.typepad.com/ciaccio

Jun 27 '08 #1
8 11749
I've got a very clunky workaroud: two buttons "Sound" and "No Sound" (see
code), but there's go to be a more elegant way :) Thanks!

Private Sub radSound_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles radSound.Click
radSound.Checke d = True
radNoSound.Chec ked = False
radSound.Visibl e = False
radNoSound.Visi ble = True
End Sub
Private Sub radNoSound_Clic k(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles radNoSound.Clic k
radNoSound.Chec ked = True
radSound.Checke d = False
radNoSound.Visi ble = False
radSound.Visibl e = True
End Sub

Jun 27 '08 #2
Jeff Ciaccio wrote:
I would like to create a toggle button, so I chose a radio and set its
apperance to button. Is seems my method always makes this .checked =
false. Can somebody help me to see the error in my ways? I'm guessing
that I just need an event that triggers before it actually changes the
value of the button.

Private Sub radSound_Click( ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles radSound.Click
If radSound.Checke d = True Then radSound.Checke d = False Else
radSound = True
End Sub
Jeff,

I'd use a Checkbox control with the Appearance set to Button instead of
the Radio control. Then you don't need any code to control what it
looks like you are trying to do. If you can tell me what you are
attempt to accomplish with the code, I'd be very willing to attempt to
help you more.

Andrew Cooper
Jun 27 '08 #3
Hey Andrew,

I just want to allow the user to toggle the sound on and off.
If you can tell me what you are
attempt to accomplish with the code, I'd be very willing to attempt to
help you more.

Andrew Cooper
Jun 27 '08 #4
Jeff Ciaccio wrote:
Hey Andrew,

I just want to allow the user to toggle the sound on and off.
>If you can tell me what you are attempt to accomplish with the code,
I'd be very willing to attempt to help you more.

Andrew Cooper
That's what I thought. Use the Checkbox control and not the Radio
control. Then all you need is the following event.

Private Sub CheckBox1_Check edChanged(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles CheckBox1.Check edChanged

If CheckBox1.Check ed = True Then
'Turn sound on.
Else
'Turn sound off.
End If
End Sub
Jun 27 '08 #5
Thanks - that did the trick. Why I didn't think of that ... :(

"Andrew Cooper" <ka************ @gmail.comwrote in message
news:OX******** ********@TK2MSF TNGP02.phx.gbl. ..
Jeff Ciaccio wrote:
>Hey Andrew,

I just want to allow the user to toggle the sound on and off.
>>If you can tell me what you are attempt to accomplish with the code, I'd
be very willing to attempt to help you more.

Andrew Cooper

That's what I thought. Use the Checkbox control and not the Radio
control. Then all you need is the following event.

Private Sub CheckBox1_Check edChanged(ByVal sender As System.Object, _
ByVal e As System.EventArg s) Handles CheckBox1.Check edChanged

If CheckBox1.Check ed = True Then
'Turn sound on.
Else
'Turn sound off.
End If
End Sub
Jun 27 '08 #6
Jeff Ciaccio wrote:
Thanks - that did the trick. Why I didn't think of that ... :(
Jeff,

Everything seems obvious after the fact. :-) If we all posted the times
we overlooked something simple everyone one of us would look pretty silly.

Andrew
Jun 27 '08 #7
On Jun 26, 10:12 pm, "Jeff Ciaccio" <non...@noreply .orgwrote:
Hey Andrew,

I just want to allow the user to toggle the sound on and off.
If you can tell me what you are
attempt to accomplish with the code, I'd be very willing to attempt to
help you more.
Andrew Cooper
You can use a checkbox to do it even with its text:

Private Sub CheckBox1_Check edChanged(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles CheckBox1.Check edChanged
If CheckBox1.Check ed = True Then
' Turn on sound - code here
' Also,
CheckBox1.Text = "Sound: ON"
ElseIf CheckBox1.Check ed = False Then
'Turn off sound
' Also,
CheckBox1.Text = "Sound: OFF"
End If

End Sub

And still if you want to use radio buttons, then you'd need 2 radio
buttons like named "radiobutto n1" and "radiobutto n2" :

Private Sub RadioButton1_Ch eckedChanged(By Val sender As
System.Object, ByVal e As System.EventArg s) Handles
RadioButton1.Ch eckedChanged
If RadioButton1.Ch ecked = True Then
'Turn on Sound - Code here
MsgBox("Sound is turned ON")
End If
End Sub

Private Sub RadioButton2_Ch eckedChanged(By Val sender As System.Object,
ByVal e As System.EventArg s) Handles RadioButton2.Ch eckedChanged
If RadioButton2.Ch ecked = True Then
' Turn off Sound - Code here
MsgBox("Sound is turned OFF")
End If
End Sub
Hope this helps,

Onur Güzel
Jun 27 '08 #8
>
Everything seems obvious after the fact. :-) If we all posted the times
we overlooked something simple everyone one of us would look pretty silly.

Andrew
Right

:-)

Cor

Jun 27 '08 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
10727
by: MarthaR | last post by:
I am trying to add the current time to a field when the user clicks on the toggle button next to the field. I am getting a time of 12:00:00 AM each time I click the button. How do I get a return of the current time? MarthaR
4
4348
by: Neil Coleclough | last post by:
I am constructing a database to process product returns for my Company. I have a number of toggle buttons to identify the stage to which each return has been processed. For example, clicking the first button confirms that the goods are now in our building awaiting initial processing. This button then fires off an email to our warehouse staff alerting them to the fact. I want to restrict these buttons to single use, so that once the email...
2
7964
by: Mel | last post by:
Hi, is there any way I can implement toolstrip toggle button simular to the MS Word alignment button? if one toggle button already pressed down, if user click on the "pushed down button", the other toggle button will push down and the "pushed down button" will push up. I have trying to find groupID for toolstrip button, but seem like they don't have it. I hope anyone can help my question, thank you very much.
3
3834
by: Killer42 | last post by:
Hi all. I have a frame with some toggle buttons in it. All is working fine, except that the user can't tell which option is selected to begin with. How do I set one of the toggle buttons to the down position at design time? (All controls are unbound). I have done some searching on TheScripts, and found a couple of cases where it was suggested to set the Down position, which is where I picked up the terminology. But couldn't seem to find...
5
10227
JustJim
by: JustJim | last post by:
Hi All I have a little application I'm working on for the local Department of Education. There is a "Main Menu" form that has a toggle button on it to show/hide the Database Window. When it is clicked it does the following Private Sub tglDBwindow_Click() DoCmd.SelectObject acTable, , True If tglDBwindow Then Me.SetFocus 'Me.tglDBwindow.DefaultValue = "True" Me.OpenArgs = True
1
4439
by: Jeffrey Christiansen | last post by:
I wanted to add a toggle button to a VB2005 form to be used for a simple Windows Application (i.e. compiled to a "*.exe"), so I added the ActiveX Microsoft Forms Object toggle button, however I can't get this button does work properly. The documentation I found in the FM20.CHM files says the button state can be determined from its "Value" property, but the property list shown in VB2005 does not have a "Value" property. How is the button...
6
4022
by: ethanhines | last post by:
I am trying to dynamically change the value of a filed using a toggle button in a form it is not a yes or no question. I want it to change a value in a table based on it"s state. Toggled on="6 inches" Toggled off=<null>. I want to more then one toggle button on the form each one dynamically changing the value of the table in real time. How do I do this?
1
2286
by: =?Utf-8?B?R3JlZw==?= | last post by:
I've been looking for a Toggle Button style control and can't seem to find anything. I want to have two buttons on the screen with only one of the two being pushed down (or true). One of the two buttons must always be pushed down and when the other one is pushed down on the other becomes false. Anyway, I'm just looking to implement a basic Toggly Style Button group. Thanks.
0
2008
by: ARC | last post by:
Hello all, In access 2007, it appears you cannot put a toggle button underneath a menu id and have it show a Pressed / Not Pressed status. If you make the toggleButton ID as part of the main ribbon on a form, it will show the pressed status. Does anyone know of any workarounds? If not, what I'm trying to do is have 2 styles of a particular form, and
0
9591
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10228
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10057
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8883
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7415
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6676
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3970
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2816
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.