VB.NET 2008/VB - 폼(Form)

Windows Forms - 대화 상자

본클라쓰 2011. 4. 10. 09:36

 

대화 상자는 사용자의 상호 작용하고 정보를 검색하는 데 사용된다. 간단히 말해서 대화 상자는 FormBorderStyle 열거형 속성이 FixedDialog로 설정된 폼이다.

 

응용 프로그램에서 다른 폼을 표시할 때와 같은 방법으로 대화 상자를 표시한다. 시작 폼은 응용 프로그램이 실행될 때 자동으로 로드된다. 응용 프로그램에 두 번째 폼 또는 대화 상자를 나타내려면 해당 폼이나 대화 상자를 로드하여 표시하는 코드를 작성한다.

 

 

MessageBox는 사용자에게 응용 프로그램 관련 정보를 표시하는 미리 정의된 대화 상자이다. 또한 사용자에게 정보를 요청할 경우에도 메시지 상자가 사용된다.

 

Public Sub PerformCalculations()

    ' Code is entered here that performs a calculation.

    ' Display a message box informing the user that the calculations are complete.

    MessageBox.Show("The calculations are complete", "My Applications", MessageBoxButtons.OKCancel, _

        MessageBoxICon.Asterisk)

 

End Sub

 

 

 

정보를 요청하는 메시지 상자를 표시하려면

 

Public Sub ExitApplication()
    ' Display a message box asking users if they
    ' want to exit the application.
    If MessageBox.Show ("Do you want to exit?", "My Application",  MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
      Application.Exit
   End If


End Sub