2013-09-06 2 views

답변

0

당신은 버튼 이벤트 핸들러에 코드를 추가해야합니다

public void Button1_Click(Object sender, EventArgs e) 
{ 
    TextBox1.Text = "1"; 
} 

string "1"텍스트 상자에 표시 할 것이다. 내가 정수로 문자열에서 변환이 성공했는지 보여줍니다 TryParse 예를 포함했다

public void Button1_Click(Object sender, EventArgs e) 
{ 
    string input1 = txtInput.Text; 
    string input2 = txtInput2.Text; 

    int userInput; 
    int userInput2; 
    int result; 

    Int32.TryParse(input1, out userInput); 
    Int32.TryParse(input2, out userInput2); 

    result = userInput + userInput2;  
    txtAnswer.Text = "The answer is: " result.ToString(); 
} 

:

당신은 웹 페이지 및 사용에 여러 텍스트 상자를도있을 수 있습니다.

+0

이 프로그램은 계산기이므로 텍스트 상자에 숫자를 추가 할 수 있습니다. – Craig

+0

@Craig - 예제가 포함되어 있습니다. –

관련 문제