VB 2010을 사용하여 문제가 있습니다 - 3 개의 라디오 버튼 중 하나를 선택하여 카펫 비용을 계산하려고합니다.VB 2010 라디오 버튼 비용 계산 양식에
여기Private CarpetPrice, UnderlayPrice As Decimal
버튼에 대한 내 코드
Private Sub CostButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CostButton.Click
' Calculate button click
' Radio Button IF Statement for calculating cost
If EconomyRadioButton.Checked Then
UnderlayPrice = 3.95 And CarpetPrice = 12.95
ElseIf DeluxeRadioButton.Checked Then
UnderlayPrice = 4.95 And CarpetPrice = 15.49
ElseIf PlushRadioButton.Checked Then
UnderlayPrice = 5.95 And CarpetPrice = 19.95
End If
' Start Calculations
CarpetNumLabel.Text = (((Length1TextBox.Text * Width1TextBox.Text)/1296) + ((Length2TextBox.Text * Width2TextBox.Text)/1296) + _
((Length3TextBox.Text * Width3TextBox.Text)/1296) + ((HallLengthTextBox.Text * HallWidthTextBox.Text)/1296)) * 1.05
UnderlayNumLabel.Text = CarpetNumLabel.Text
TackNumLabel.Text = ((Length1TextBox.Text/96) + (Width1TextBox.Text/96) + (Length2TextBox.Text/96) + (Width2TextBox.Text/96) _
+ (Length3TextBox.Text/96) + (Width3TextBox.Text/96) + (HallLengthTextBox.Text/96) + (HallWidthTextBox.Text/96)) * 1.1
ScrewNumLabel.Text = ((TackNumLabel.Text/1.1) * 8)/50
CarpetCostLabel.Text = CarpetNumLabel.Text * CarpetPrice
UnderlayCostLabel.Text = UnderlayNumLabel.Text * UnderlayPrice
TackCostLabel.Text = TackNumLabel.Text
ScrewCostLabel.Text = ScrewNumLabel.Text * 2.85
End Sub
는 지금 모든 카펫을 제외하고 완벽한 실행을 클릭하고, 언더는 계산하지 않습니다
나는 내 양식의 상단이 있습니다 가격. 버튼을 클릭 할 때 프로그램이 라디오 버튼의 상태를 인식하도록하려면 다른 작업을해야합니까? 어떤 도움 주셔서 감사합니다
CarpetCostLabel.Text = CarpetNumLabel.Text * CarpetPrice
UnderlayCostLabel.Text = UnderlayNumLabel.Text * UnderlayPrice
: -
나는 내 문제가에서 생각합니다.
"AND"를 사용하여 IF 블록에서 한 줄로 두 개의 과제를 수행 할 수 있다고 생각하지 않습니다. – Jesse
당신이 옳다고 생각합니다. 방금 반을 제거했고 밑받침만으로도 효과가있었습니다. 카펫면에 다른 IF 블록을 추가해야 할 것 같네요. –
차단하려면 다른 블록이 필요하지 않습니다. AND를 빼고 두 번째 할당을 새 행에 넣으십시오. – Jesse