简体   繁体   English

如何在Windows VB.net中使用单选按钮进行编码?

[英]How to code using radio buttons in VB.net for Windows?

So I am having difficulty coding with radio buttons. 所以我很难用单选按钮编码。 I have 4 radio buttons in 2 different lists. 我在2个不同的列表中有4个单选按钮。

Status     
 - Member  
 - Non Member

Age  
 - Over 65  
 - Under 65  

Fee Box        Display Button


If
  Member and Over 65 = $5 
ElseIf 
  Non Member and Under 65 = $50
ElseIf 
  Member and Under 65 = $5
ElseIf
  Non Member and Over 65 = 50$

Sorry if that was confusing, any help works thankyoU! 不好意思,很抱歉,任何帮助都可以解决!

Edit: 编辑:

Hey guys! 大家好! My teacher ended up helping me thankyou though! 我的老师最后还是帮我谢谢你!

Assuming you are using WinForms and the WinForm designer to put radio buttons on the form, you should be able to handle the change event for the radio buttons. 假设您正在使用WinForms和WinForm设计器在窗体上放置单选按钮,则应该能够处理单选按钮的change事件。 You can use the same change event for all the radio buttons and just setup your calculation there (there are better ways of doing it, but this is a very simple way to do it). 您可以对所有单选按钮使用相同的change事件,然后在此处进行设置即可(有更好的方法,但这是一种非常简单的方法)。

From memory (I haven't done VB.Net in a couple years)... 从记忆中(我几年没有做过VB.Net)...

Public Sub Radio_Changed(sender As Object, e As EventArgs) Handles Radio1.Changed, Radio2.Changed, Radio3.Changed, Radio4.Changed
    If Member Then
        Cost = 5
    Else
        Cost = 50
    End If
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM