* VS.NET을 처음 해보시는 분들 위주로 작성하였습니다.
한번정도 사용해 보신 분이라면 이번 강의는 넘어가세요~ ^^
InputBox에 텍스트를 입력하면 윈도우에 표시되도록 하는 간단한 예제를 해보겠습니다.
VS.NET을 실행합니다.
메뉴에서 '파일(F)' -> '새로만들기(N)' -> '프로젝트(P)'를 누르면
'새 프로젝트' 윈도우가 나타납니다.
메뉴바에 있는 '새 프로젝트 (ctrl+shift+N)'로 열어도 됩니다.
프로젝트이름과 저장할 위치를 지정 후 확인합니다.
생성된 폼위에 Label과 Button 2개를 올려놓습니다.
컨트롤들의 이름과 속성은 임의로 변경하시면 됩니다.
버튼1을 더블클릭하여 버튼1 클릭 이벤트에 inputBox 창을 띄워 입력받은
값이 Label에 나타나도록 코딩합니다.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strInput As String
'입력박스에서 문자를 입력받는다.
strInput = InputBox("글자를 입력해주세요", "VB.NET!!")
'입력받은 값을 Label 값으로 대입한다.
Label1.Text = strINput
End Sub
버튼2를 더블클릭하여 버튼2 클릭 이벤트 발생 시 폼이 닫히도록 코딩합니다.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'form을 닫는다
Me.Close()
End Sub
코딩이 다 되었으면 실행합니다.
"Ctrl+Shift+B"를 눌러 빌드하고 F5를 눌러 실행합니다.
'************************************************************
전체소스
'************************************************************
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form 디자이너에서 생성한 코드 "
Public Sub New()
MyBase.New()
'이 호출은 Windows Form 디자이너에 필요합니다.
InitializeComponent()
'InitializeComponent()를 호출한 다음에 초기화 작업을 추가하십시오.
End Sub
'Form은 Dispose를 재정의하여 구성 요소 목록을 정리합니다.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows Form 디자이너에 필요합니다.
Private components As System.ComponentModel.IContainer
'참고: 다음 프로시저는 Windows Form 디자이너에 필요합니다.
'Windows Form 디자이너를 사용하여 수정할 수 있습니다.
'코드 편집기를 사용하여 수정하지 마십시오.
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.Label1 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(24, 88)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(96, 40)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Button1"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(240, 88)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(96, 40)
Me.Button2.TabIndex = 1
Me.Button2.Text = "Button2"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(24, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(312, 32)
Me.Label1.TabIndex = 2
Me.Label1.Text = "Label1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(368, 158)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strInput As String
'입력박스에서 문자를 입력받는다.
strInput = InputBox("글자를 입력해주세요", "VB.NET!!")
'입력받은 값을 Label 값으로 대입한다.
Label1.Text = strINput
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'form을 닫는다
Me.Close()
End Sub
End Class
'************************************************************
한번정도 사용해 보신 분이라면 이번 강의는 넘어가세요~ ^^
InputBox에 텍스트를 입력하면 윈도우에 표시되도록 하는 간단한 예제를 해보겠습니다.
VS.NET을 실행합니다.
메뉴에서 '파일(F)' -> '새로만들기(N)' -> '프로젝트(P)'를 누르면
'새 프로젝트' 윈도우가 나타납니다.
메뉴바에 있는 '새 프로젝트 (ctrl+shift+N)'로 열어도 됩니다.
프로젝트이름과 저장할 위치를 지정 후 확인합니다.
생성된 폼위에 Label과 Button 2개를 올려놓습니다.
컨트롤들의 이름과 속성은 임의로 변경하시면 됩니다.
버튼1을 더블클릭하여 버튼1 클릭 이벤트에 inputBox 창을 띄워 입력받은
값이 Label에 나타나도록 코딩합니다.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strInput As String
'입력박스에서 문자를 입력받는다.
strInput = InputBox("글자를 입력해주세요", "VB.NET!!")
'입력받은 값을 Label 값으로 대입한다.
Label1.Text = strINput
End Sub
버튼2를 더블클릭하여 버튼2 클릭 이벤트 발생 시 폼이 닫히도록 코딩합니다.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'form을 닫는다
Me.Close()
End Sub
코딩이 다 되었으면 실행합니다.
"Ctrl+Shift+B"를 눌러 빌드하고 F5를 눌러 실행합니다.
'************************************************************
전체소스
'************************************************************
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form 디자이너에서 생성한 코드 "
Public Sub New()
MyBase.New()
'이 호출은 Windows Form 디자이너에 필요합니다.
InitializeComponent()
'InitializeComponent()를 호출한 다음에 초기화 작업을 추가하십시오.
End Sub
'Form은 Dispose를 재정의하여 구성 요소 목록을 정리합니다.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows Form 디자이너에 필요합니다.
Private components As System.ComponentModel.IContainer
'참고: 다음 프로시저는 Windows Form 디자이너에 필요합니다.
'Windows Form 디자이너를 사용하여 수정할 수 있습니다.
'코드 편집기를 사용하여 수정하지 마십시오.
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
Me.Label1 = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(24, 88)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(96, 40)
Me.Button1.TabIndex = 0
Me.Button1.Text = "Button1"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(240, 88)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(96, 40)
Me.Button2.TabIndex = 1
Me.Button2.Text = "Button2"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(24, 24)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(312, 32)
Me.Label1.TabIndex = 2
Me.Label1.Text = "Label1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(368, 158)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.Button2)
Me.Controls.Add(Me.Button1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strInput As String
'입력박스에서 문자를 입력받는다.
strInput = InputBox("글자를 입력해주세요", "VB.NET!!")
'입력받은 값을 Label 값으로 대입한다.
Label1.Text = strINput
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'form을 닫는다
Me.Close()
End Sub
End Class
'************************************************************
![]() | ![]() ![]() | 12-27 | 2520 | |
![]() | ![]() ![]() | 12-11 | 1849 | |
53 | ![]() ![]() | 03-15 | 1657 | |
52 | ![]() ![]() | 01-31 | 1746 | |
51 | ![]() ![]() | 01-31 | 2516 | |
50 | ![]() ![]() | 01-31 | 1391 | |
49 | ![]() ![]() | 01-19 | 1691 | |
48 | ![]() ![]() | 01-11 | 1579 | |
47 | ![]() ![]() | 01-03 | 2094 | |
46 | ![]() ![]() | 12-27 | 2520 | |
45 | ![]() ![]() | 12-19 | 1808 | |
44 | ![]() ![]() | 12-14 | 1791 | |
43 | ![]() ![]() | 12-11 | 1849 | |
42 | ![]() ![]() | 12-09 | 1451 | |
41 | ![]() ![]() | 12-01 | 1674 | |
40 | ![]() ![]() | 12-01 | 1849 | |
39 | ![]() ![]() | 12-01 | 1320 |
댓글 없음:
댓글 쓰기