2013-02-24 2 views
0

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 

: -

나는 내 문제가에서 생각합니다.

+0

"AND"를 사용하여 IF 블록에서 한 줄로 두 개의 과제를 수행 할 수 있다고 생각하지 않습니다. – Jesse

+0

당신이 옳다고 생각합니다. 방금 반을 제거했고 밑받침만으로도 효과가있었습니다. 카펫면에 다른 IF 블록을 추가해야 할 것 같네요. –

+1

차단하려면 다른 블록이 필요하지 않습니다. AND를 빼고 두 번째 할당을 새 행에 넣으십시오. – Jesse

답변

2

AND를 사용하여 서로 다른 두 개의 지정을 문자열로 묶을 수는 없습니다. 귀하의 IF 블록이

If EconomyRadioButton.Checked Then 
    UnderlayPrice = 3.95 
    CarpetPrice = 12.95 
ElseIf DeluxeRadioButton.Checked Then 
    UnderlayPrice = 4.95 
    CarpetPrice = 15.49 
ElseIf PlushRadioButton.Checked Then 
    UnderlayPrice = 5.95 
    CarpetPrice = 19.95 
End If 
+0

그레이트 픽업! 기꺼이 도왔습니다. – Jeremy

+0

고마워요. @ 제레미 칠드, 가끔씩 우리를 괴롭히는 작은 것들, 그냥 신선한 눈이 필요해. – Jesse

+0

감사! 정답으로 표시 –

-1

사용 변수이어야하며 if 문에서 사용 AND 연산자를하지 않습니다 ... ADN 연산자는 A 조건 < (20)과> (10)가 다음 UNT

을 시도 ..try 경우와 같은 경우에 사용할 수있다