체크박스 라디오박스
여러항목 선택 가능 한 항복 선택 가능
세가지 상태 사용 두가지 상태 사용
속성  
Chcked 선택여부
true : 선택된 경우 / false : 선택되지 않은 경우
체크박스 
특징
CheckState 체크박스 초기 선택 상태
Unchecked : 체크되지 않은 상태
Checked : 체크된 상태
Indeterminate : 체크되고 비활성화 상태
ThreeState indeterminate 사용 가능 여부 설정
true :  세가지 선택 상태 / false : 두가지 선택 상태
체크박스 예제

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim str As String

        If CheckBox1.Checked = True Then str = CheckBox1.Text & Chr(13)
        If CheckBox2.Checked = True Then str = str & CheckBox2.Text & Chr(13)
        If CheckBox3.Checked = True Then str = str & CheckBox3.Text & Chr(13)
        If CheckBox4.Checked = True Then str = str & CheckBox4.Text & Chr(13)
        If CheckBox5.Checked = True Then str = str & CheckBox5.Text & Chr(13)
        If CheckBox6.Checked = True Then str = str & CheckBox6.Text & Chr(13)

        Label2.Text = str
    End Sub
End Class
라디오버튼 예제

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If RadioButton1.Checked = True Then Label2.Text = RadioButton1.Text
        If RadioButton2.Checked = True Then Label2.Text = RadioButton2.Text
        If RadioButton3.Checked = True Then Label2.Text = RadioButton3.Text
        If RadioButton4.Checked = True Then Label2.Text = RadioButton4.Text
        If RadioButton5.Checked = True Then Label2.Text = RadioButton5.Text
        If RadioButton6.Checked = True Then Label2.Text = RadioButton6.Text
    End Sub
End Class
그룹박스 컨트롤 예제

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        Dim str As String

        str = "연령은" + Chr(13)
        If RadioButton1.Checked = True Then str = str + RadioButton1.Text
        If RadioButton2.Checked = True Then str = str + RadioButton2.Text
        If RadioButton3.Checked = True Then str = str + RadioButton3.Text
        If RadioButton4.Checked = True Then str = str + RadioButton4.Text
        If RadioButton5.Checked = True Then str = str + RadioButton5.Text
        If RadioButton6.Checked = True Then str = str + RadioButton6.Text

        str = str + Chr(13) + "좋아하는 색은" + Chr(13)
        If CheckBox1.Checked = True Then str = str + CheckBox1.Text + Chr(13)
        If CheckBox2.Checked = True Then str = str + CheckBox2.Text + Chr(13)
        If CheckBox3.Checked = True Then str = str + CheckBox3.Text + Chr(13)
        If CheckBox4.Checked = True Then str = str + CheckBox4.Text + Chr(13)
        If CheckBox5.Checked = True Then str = str + CheckBox5.Text + Chr(13)
        If CheckBox6.Checked = True Then str = str + CheckBox6.Text + Chr(13)

        str = str + "입니다"
        Label2.Text = str
    End Sub

End Class

레이블의 속성값은 버튼과 별 다른 차이없다.

 

Visual Basic 버튼 컨트롤

다양한 속성들 VB.Net - Button Control VB.Net - Button Control The Button control represents a standard Windows button. It is generally used to generate a Click event by providing a handler for the C..

zzerou.tistory.com

 

텍스트 박스의 경우 조금 다른데

종류 이름 설명
속성 AcceptsReturn enter 입력시 기능 설정
true : multiLine속성이 true인 경우 줄바꿈기능 추가
false : 
BorderStyle 테두리 모양
Locked 텍스트 편집 가능 여부 설정
true : 편집불가 / false : 편집가능
MaxLength 입력할 수 있는 최대 문자 수
MultiLine 텍스트 여러줄 입력 여부
true : 여러줄 /  false : 한줄
PasswordChar 입력한 문자 출력 대신, 설정문자 출력
(암호 입력프로그램에서 사용)
ScrollBars 수평/수직 스크롤바 생성 여부 설정
** MultiLine속성이 true로 설정**
WordWrap 여러줄 입력시 자동 줄 바꿈
true: 줄바꿈 / false : 줄바꿈X
메서드 Move 폼에서 텍스트박스 위치 설정
SetFocus 텍스트박스 포커스
이벤트 KeyPress 포커스 둔 상태에서 특수키 외의 키(alt, shift, crl)를 누를때 발생
TextChanged 텍스트 속성 값 변하면 발생

textbox1 - MultiLine,AcceptsReturn, WordWrap

textbox2 - ScrollBars:both, TextAlign , PasswordChar

textbox3  - ReadOnly, Locked

 

활용 1

좌) 실행전, 우) 실행후

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Label3.Text = "환영합니다."
    End Sub
End Class

현재로서는 비밀번호/아이디를 입력하지 않아도 버튼클릭시 label3의 해당 문구 출력가능

 

활용 2

public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Label3.Text = TextBox1.Text + "의 비밀은 " + TextBox2.Text + "이래요"
    End Sub
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Label3.Text = "다시입력하세요"
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox1.Focus()
    End Sub
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        End
    End Sub

 

다양한 속성들
 

VB.Net - Button Control

VB.Net - Button Control The Button control represents a standard Windows button. It is generally used to generate a Click event by providing a handler for the Click event. Let's create a label by dragging a Button control from the Toolbox ad dropping it on

www.tutorialspoint.com

 

버튼 이벤트
종류 이름 설명
이벤트 Click 마우스 버튼을 눌렀을 때 발생
KeyPress 키보드 키 눌렀다 놓았을 때 발생
KeyDown 키보드의 키를 눌렀을 때 발생
KeyUp 키보드의 키를 놓았을 때 발생

 

헝가리안 표기법으로 이름 설정 많이 함

개체 형식 접두사 예시
frm frmMain
프레임 fra fraLanguage
버튼 컨트롤 btn btnExit
레이블 lbl lblHelpMessage
텍스트박스 txt txtLastName
체크박스 chk chkReadOnly
라디오버튼 rb rbColor
이미지 img imgIcon
리스트박스 lst lstPolicyCodes

 

컨트롤 속성과 메서드 사용

컨트롤명.속성 = 속성값

   Text.Text = "Text 속성"

   +) 메서드는 개체가 수행하는 동작이나 기능을 정의한 것으로 컨트롤에 속한 여러 함수의미

 

Visual Basic 주석

작은따옴표(아포스트로피, ')로 표현
개체 : 실제로 존재하는 것

      - 특성(속성), 기능(메서드), 행위(이벤트)를 가짐

속성 : 개체의 색상, 크기, 위치 같은 외형 정의
메서드 : 개체가 수행하는 동작이나 기능 정의
이벤트 : 개체가 반응할 수 있는 특정 사건
프로시저 : 이벤트 처리단위 , 행동 수행하기 위한 작업순서

이 이후로 다음으로 계속 넘어가면 된다.

+ Recent posts