Lab 7
Lab 7. Intro VB. ฝึกใช้ Label, TextBox, Command Button, MsgBox. Form. Label. TextBox. Command Button. ฝึกใช้ Label, TextBox, Command Button, MsgBox. ฝึกใช้ Label, TextBox, Command Button, MsgBox. Private Sub cmdShow _Click ()
Lab 7
E N D
Presentation Transcript
Lab 7 Intro VB
ฝึกใช้ Label, TextBox, Command Button, MsgBox Form Label TextBox Command Button
ฝึกใช้ Label, TextBox, Command Button, MsgBox Private Sub cmdShow_Click() MsgBoxtxtName.Text& " is " &txtAge.Text & " years olds.",vbExclamation, "Detail" End Sub
ฝึกใช้ Label, TextBox, Command Button, MsgBox Private Sub cmdShow_Click() MsgBoxtxtName.Text & " is " & txtAge.Text & " years olds.",vbExclamation, "Detail" End Sub
ฝึกใช้ Label, TextBox, Command Button, MsgBox Private Sub cmdEnd_Click() End End Sub
ข้อ 1.3 สร้าง GUI สำหรับการ Login ของผู้ใช้ดังรูป
1.4 เมื่อผู้ใช้คลิ๊ก “OK” ให้แสดงข้อความดังตัวอย่าง Private Sub cmdOK_Click() MsgBox“Password incorrect. Please try again.",vbExclamation, “Warning" End Sub
1.5เมื่อผู้ใช้คลิ๊ก “Cancel” ให้ลบข้อมูลที่อยู่ใน text box ออกให้หมด Private Sub cmdCancel_Click() txtUserName.Text = “” txtPassword.Text = “” End Sub
การใช้ MsgBox • รูปแบบ MsgBoxPrompt[,Buttons + Sign] [,Title] MsgBoxชื่อคำสั่ง Prompt ข้อความที่ให้แสดงบน Message Box [,Buttons + Sign] ปุ่มและสัญลักษณ์ [,Title] ชื่อเรื่อง
การใช้ MsgBox • Buttons (ปุ่ม) เช่น • vbOKOnly • vbOKCancel • vbYesNo • Signs (สัญลักษณ์) • vbCritical • vbExclamation • vbInformation • vbQuestion • ตัวอย่าง • MsgBox“Can you speak Thai?” ,vbYesNo + vbQuestion,“Question"