<< Chapter < Page Chapter >> Page >

Private Type yeucau

ho As String

ten As String

manv As String

sodt As String

socmnd As String

tinhtranghn As String

End Type

Bước 7: Ta thêm 2 biến nữa; một biến lưu thông tin về người sử dụng (theo kiểu ở trên), một biến lưu thứ tự các bước mà người sử dụng đã nhập thông tin của mình vào.

Private chisobuoc As Integer

Private cacyeucau As yeucau

Bước 8: Trong chương trình này, người sử dụng phải nhập thông tin của mình vào thông qua các bước nhập, trong đó các điều khiển được sử dụng như một mảng các điều khiển. Để tận dụng chúng ta cần khai báo các hằng số để biết hiện thời người dùng đang ở bước thứ mấy của quá trình nhập thông tin cũng như biết được mình đã nhấp vào nút nhấn nào trong quá trình trên. Do đó, ta thêm đoạn khai báo sau:

' cac hang so

Private Enum buoc

buoc1 = 1

buoc2 = 2

buoc3 = 3

End Enum

Private Enum nhannut

nuttrai

nutgiua

nutphai

End Enum

Bước 9: Chương trình này thể hiện trên một form duy nhất và sử dụng mảng các điều khiển để tạo các bước để người dùng nhập thông tin vào. Do đó ta sử dụng tập tin tài nguyên để hiển thị các tên của điều khiển nhằm hiển thị cho chính xác. Vì thế ta cần có một hàm (thủ tục) để cập nhật thông tin nhập vào dựa vào các bước của người dung khi nhập thông tin vào. Vào Tools\Add Procedure để thêm thủ tục sau:

Public Sub Hienthi()

Dim i As Integer

' Kiem tra cac buoc

Debug.Assert chisobuoc = 1 Or chisobuoc = 2

For i = 0 To 2

‘ Nhan

lblHelp(i).Caption = LoadResString((chisobuoc - 1) * 6 + (i + 1))

' Nut

cmdHelp(i).Caption = LoadResString((chisobuoc - 1) * 6 + (i + 4))

If UCase(cmdHelp(i).Caption) = "VO HIEU HOA" Then

cmdHelp(i).Visible = False

Else

cmdHelp(i).Visible = True

End If

txtHelp(i).Text = ""

Next

End Sub

Bước 10: Khi chương trình thực hiện, ta phải ở bước thứ nhất của quá trình nhập liệu size 12{ drarrow } {} Thêm đoạn mã sau trong thủ tục xử lý sự kiện Form_Load:

chisobuoc = 1

Hienthi

Bước 11: Mỗi khi có một nút nhấn được nhấp, quá trình nhập liệu chuyển sang bước kế tiếp; người sử dụng có thể đi đến bước kế tiếp hay trở về bước trước đó trong quá trình này. Vì các nút nhấn (button) là một mảng điều khiển (control array) nên chúng có cùng một sự kiện Click tác động vào gọi là cmdHelp_Click. Hàm xử lý này có tham số là một chỉ số kiểu Integer để nhận biết nút nhấn nào được nhấp. Ở đây, ta thêm đoạn mã sau trong hàm xử lý sự kiện này.

Private Sub cmdHelp_Click(Index As Integer)

Select Case chisobuoc

Case buoc1

cacyeucau.ten = txtHelp(0).Text

cacyeucau.ho = txtHelp(1).Text

cacyeucau.manv = txtHelp(2).Text

Case buoc2

cacyeucau.sodt = txtHelp(0).Text

cacyeucau.socmnd = txtHelp(1).Text

cacyeucau.tinhtranghn = txtHelp(2).Text

End Select

' Cac nut nhan

Select Case Index

Case nuttrai

' Huy bo

End

Case nutgiua

' ve truoc

chisobuoc = buoc1

Hienthi

Case nutphai

' di toi

chisobuoc = chisobuoc + 1

If chisobuoc = buoc2 Then

Hienthi

Else

Guiyeucau

End If

End Select

End Sub

Bước 12: Khi quá trình nhập thông tin kết thúc, thông tin này được lưu vào trong một tập tin văn bản, nhờ thủ tục Guiyeucau. Thêm thủ tục Guiyeucau vào nhờ mục Tools\Add Procedure và nhập đoạn mã sau:

Public Sub Guiyeucau()

On Error GoTo Guiloi

Questions & Answers

what is biology
Hajah Reply
the study of living organisms and their interactions with one another and their environments
AI-Robot
what is biology
Victoria Reply
HOW CAN MAN ORGAN FUNCTION
Alfred Reply
the diagram of the digestive system
Assiatu Reply
allimentary cannel
Ogenrwot
How does twins formed
William Reply
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
what is genetics
Josephine Reply
Genetics is the study of heredity
Misack
how does twins formed?
Misack
What is manual
Hassan Reply
discuss biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles
Joseph Reply
what is biology
Yousuf Reply
the study of living organisms and their interactions with one another and their environment.
Wine
discuss the biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles in an essay form
Joseph Reply
what is the blood cells
Shaker Reply
list any five characteristics of the blood cells
Shaker
lack electricity and its more savely than electronic microscope because its naturally by using of light
Abdullahi Reply
advantage of electronic microscope is easily and clearly while disadvantage is dangerous because its electronic. advantage of light microscope is savely and naturally by sun while disadvantage is not easily,means its not sharp and not clear
Abdullahi
cell theory state that every organisms composed of one or more cell,cell is the basic unit of life
Abdullahi
is like gone fail us
DENG
cells is the basic structure and functions of all living things
Ramadan
What is classification
ISCONT Reply
is organisms that are similar into groups called tara
Yamosa
in what situation (s) would be the use of a scanning electron microscope be ideal and why?
Kenna Reply
A scanning electron microscope (SEM) is ideal for situations requiring high-resolution imaging of surfaces. It is commonly used in materials science, biology, and geology to examine the topography and composition of samples at a nanoscale level. SEM is particularly useful for studying fine details,
Hilary
cell is the building block of life.
Condoleezza Reply
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Giáo trình visual basic. OpenStax CNX. Jul 29, 2009 Download for free at http://cnx.org/content/col10777/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Giáo trình visual basic' conversation and receive update notifications?

Ask