-
엑셀VBA 사용자 정의 폼을 사용해 로그인 기능 만들기 #1Dung--[엑셀] 2023. 4. 4. 18:08
엑셀VBA 사용자 정의 폼을 사용해 로그인 기능 만들기 #1
사용자의 정의 폼을 활용하면 일반 프로그램과 같이 UI를 가진 엑셀을 제작할 수 있습니다. 이번에 보실 예제가 로그인 폼인데 아이디/패스워드를 입력하여야 엑셀이 열리는 구조입니다. 컴퓨터에서 쓰는 프로그램을 사용할때 로그인 폼이 있는 것들이 간혹 있습니다.
1. VBA 에디터에서의 사용자 정의 폼을 추가하기 위해서 삽입 > 사용자 정의 폼을 클릭해봅니다.
2. 아래와 같이 폼이 형성이되고 옆에 도구상자 팝업이 나오게 됩니다. 도구상자에 있는 컨트롤을 하나씩 옮겨 폼을 구성하면 됩니다.
3. 프로그램을 하는 분들은 그렇게 필요성이 없지만 엑셀만 사용하시는 분들은 생소할 수 있으므로 조금 상세하게 설명을 하겠습니다. 로그인화면을 위해서 컨트롤 들을 폼에 가져가서 화면을 구성합니다. 컨트롤들을 가져다가 놓았으면 속성값을 입력합니다. 속성은 컨트롤의 이름, 화면에 보이면 이름등을 입력할 수 있는 속성창이 있습니다. 컨트롤을 선택하고 왼쪽 아래로 내려가면 속성창이 있습니다. 컨트롤을 선택하고 텍스트상자, 레이블에 이름을 설정합니다.
4. 우선적으로 설정해야 하는것이 "이름"과 Caption 속성입니다 "이름"은 나중에 프로그램 코드에 접근하기 위한 개체명이고 caption은 단순히 화면에서 보이는 이름입니다. 하단과 같이 텍스트박스는 caption이 없습니다. 입력만 받기 때문이죠.
5. 레이블은 제외하고 소스에서 사용할 개체의 이름은 하단과 같습니다.
① txtId
② txtPwd
③ btnConfirm
④ btnClose6. 이제 3,4번에 해당되는 버튼 컨트롤의 이벤트를 등록할 것입니다. 클릭을 하였을때 기능을 수행하기 위해서입니다. 확인은 아이디, 패스워드 값을 읽어와서 검증하는 기능들이 들어갈 것이고, 종료버튼은 화면을 닫겠습니다. 이 두가지 기능을 구현하기 위하여서는 폼에 버튼을 더블 클릭합니다. 그러면 함수가 만들어지며 에디터가 자동으로 나오게 될것입니다.
7. 로그인을 확인하는 btnConfirm_click() 함수를 구현하기 위하여서는 준비를 먼저 하여야 합니다. 아이디,패스워드 정보가 저장되어있는 시트가 있어야 합니다. 그래야지만 폼에 아이디와 패스워드를 입력하였을때 확인할 수 있기 때문입니다. 아래 그림과 같이 시트명을 "사용자정보"로 하고 시트에 로그인 아이디와 패스워드를 추가합니다. 여기에 있는 정보를 검색하여서 로그인 여부를 판단합니다.
엑셀VBA 사용자 정의 폼을 사용해 로그인 기능 만들기 #2 :: 만물주머니 (tistory.com)
엑셀VBA 사용자 정의 폼을 사용해 로그인 기능 만들기 #3 :: 만물주머니 (tistory.com)
'Dung--[엑셀]' 카테고리의 다른 글
엑셀VBA 사용자 정의 폼을 사용해 로그인 기능 만들기 #3 (0) 2023.04.04 엑셀VBA 사용자 정의 폼을 사용해 로그인 기능 만들기 #2 (0) 2023.04.04 엑셀 VBA PrintPreview, PrintOut 함수 인쇄미리보기 인쇄하기 (0) 2023.04.04 엑셀 VBA Union과 Intersect 함수를 활용한 영역의 합집합,교집합 (0) 2023.04.04 엑셀 VBA Areas 속성을 활용하여 영역에 셀 개수 확인 (0) 2023.04.04