【问题标题】:Need help GroupBoxes - and radio buttons I am very new to VB需要帮助 GroupBoxes - 和单选按钮 我对 VB 很陌生
【发布时间】:2012-12-23 16:22:20
【问题描述】:

我想制作一个程序,该程序取决于某人单击的单选按钮(每个 GroupBox 只有一个按钮)和总共 5 个不同的组框。特定值将添加到输入的 num1Textbox 值中。

问题是可以做到吗?还是我在浪费时间尝试学习它。我对 VB 很陌生.. 并且只完成了一个 cpl 程序,用于为高尔夫程序添加 - 多 - 除和减值以进行推杆.. 这一次我知道它会更复杂。

下面是程序的图片。

有人会进入 Yard to Hole = 145(每次都是不同的数字)

然后他们会为每个 GroupBox 选择 1 个单选按钮(5 个不同的选项),值 145 会根据选择的选项相应地增加或减少。

抱歉,这里不允许我上传图片:(所以我在这里上传了。

抱歉,不知道您需要一个帐户才能在那里查看表格。我会尝试找到一个新的地方。 1 分钟

让我们在这里试试 http://i1311.photobucket.com/albums/s667/Steve_Lunney/design_zps9c2f89da.jpg

任何帮助将不胜感激...提前谢谢您

这就是我正在尝试的……作为某人的建议

但是在每个这些状态下 spinGroupBox.spin1RadioButton.Checked 我得到波浪线,当我将鼠标放在它上面时它说 - 'upRadioButton' 不是'System.Windows.Forms.Groupbox'的成员”

Private Sub calculateButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles calculateButton.Click
    Dim spinGroupBox As New GroupBox()
    Dim spin1RadioButton As RadioButton
    Dim spin2RadioButton As RadioButton
    Dim spin3RadioButton As RadioButton
    Dim spin4RadioButton As RadioButton
    Dim spin5RadioButton As RadioButton
    Dim num1TextBox As Integer
    Dim num2TextBox As Integer
    Dim spin1b As Decimal
    Dim resultA As Integer

    Select Case True
        Case spinGroupBox.spin1RadioButton.Checked
            spin1b = 0.095
        Case spinGroupBox.spin2RadioButton.Checked
            spin1b = 0.085
        Case spinGroupBox.spin3RadioButton.Checked
            spin1b = 0.08
            'etc
    End Select
    resultA = spin1b

    ' Create and initialize a GroupBox and a Button control. 
    Dim windGroupBox As GroupBox
    Dim upRadioButton As RadioButton
    Dim ulRadioButton As RadioButton
    Dim urRadioButton As RadioButton
    Dim downRadioButton As RadioButton
    Dim dlRadioButton As RadioButton
    Dim drRadioButton As RadioButton
    Dim leftRadioButton As RadioButton
    Dim rightRadioButton As RadioButton
    Dim wind1b As Decimal
    Dim resultb As Integer
    Select Case True
        Case windGroupBox.upRadioButton.Checked
            wind1b = 0.095
        Case windGroupBox.ulRadioButton.Checked
            wind1b = 0.085
        Case windGroupBox.urRadioButton.Checked
            wind1b = 0.075
        Case windGroupBox.downRadioButton.Checked
            wind1b = 0.07
        Case windGroupBox.dlRadioButton.Checked
            wind1b = 0.065
        Case windGroupBox.drRadioButton.Checked
            wind1b = 0.06
        Case windGroupBox.leftRadioButton.Checked
            wind1b = 0.055
        Case windGroupBox.rightRadioButton.Checked
            wind1b = 0.05

    End Select
    resultb = wind1b
End Sub

【问题讨论】:

  • ...那么图片在哪里? :)
  • 这不是一个很好的功能规范。最大的问题是你完全忘了问一个问题。这是必需的。
  • 如果upRadioButton 不是wind1b 的子级,那么它可能是表单的直接子级。你用什么来设计? (...除了 Visual Studio 之外的任何东西?)
  • 我唯一尝试使用的是 Visual Basic Express 版本...我以前从未做过任何编程,并尝试在进行过程中自学

标签: vb.net


【解决方案1】:

我现在已经对其进行了测试,正如我在评论中发布的那样,upRadioButton(以及所有其他人)(很可能)是该表单的直接子代。这意味着你可以写
Case Me.upRadioButton.Checked
(或者你可以省略Me.) 顺便说一句,如果您已将控件拉到设计器中的表单上,则应删除那些 dim ... 行。控件在另一个默认隐藏的文件中声明。您的行再次声明了隐藏对实际表单控件的访问的变量,这意味着当您尝试在没有Me. 的情况下访问它们时会出错。

【讨论】:

    猜你喜欢
    • 2013-02-24
    • 2011-09-02
    • 1970-01-01
    • 1970-01-01
    • 2010-11-13
    • 2013-10-09
    • 1970-01-01
    • 2018-02-04
    • 2016-02-08
    相关资源
    最近更新 更多