การกำหนดการตรวจสอบค่าที่กรอกใน form

เริ่มโดย thanapol.w, 26 ก.พ 20 , 13:18:51

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

thanapol.w

ขอทราบวิธีการกำหนดการตรวจสอบ ค่าที่ผู้ใช้กรอก ใน Ctl บน form

1. บ้านเลขที่ ให้เป็นตัวเลขและ มี / ได้  (ในtbl ประเภทข้อมูลเป็นText)
2. ชื่อไทย = เฉพาะอักษรไทย   NameEN = เฉพาะอักษรภาษาอังกฤษ
3. เบอร์ = ตัวเลข ใน tbl เป็น text
  •  

PNR

อ้างถึงบ้านเลขที่ ให้เป็นตัวเลขและ มี / ได้
Private Sub txtAddress_KeyPress(KeyAscii As Integer)
If (KeyAscii > 46 And KeyAscii < 58)  Then
      KeyAscii = KeyAscii
      Else:
      KeyAscii = 0
   End If
End Sub

อ้างถึง3. เบอร์ = ตัวเลข ใน tbl เป็น text

สมมุติ txtPhoneNumber

Private Sub txtPhoneNumber_KeyPress(KeyAscii As Integer)
If (KeyAscii > 47 And KeyAscii < 58) Or (KeyAscii = 8) Then
      KeyAscii = KeyAscii
      Else:
      KeyAscii = 0
   End If
End Sub

จะพิมพ์ได้เฉพาะตัวเลขครับ แต่สามารถใช้ Space Bar ได้ เผื่อว่าต้องการพิมพ์เบอร์ 000 0000000  แบบนี้
อ้างถึงNameEN = เฉพาะอักษรภาษาอังกฤษ

Private Sub txtWordsEng_KeyPress(KeyAscii As Integer)
If (KeyAscii > 65 And KeyAscii < 90) Or (KeyAscii > 97 And KeyAscii < 122) Then
KeyAscii = KeyAscii
      Else:
      KeyAscii = 0
End If
End Sub
อ้างถึงชื่อไทย = เฉพาะอักษรไทย
Private Sub txtWordsTH_KeyPress(KeyAscii As Integer)
If Not (KeyAscii > 0 And KeyAscii < 32) And Not (KeyAscii > 32 And KeyAscii < 127) Then
KeyAscii = KeyAscii
      Else:
      KeyAscii = 0
End If
End Sub

สำหรับ ใส่ชื่อไทย กำหนดให้ยอมรับการกด Spacebar ได้เพื่อให้เว้นช่องว่างกรณี มีทั้งชื่อและนามสกุล
Time to stop for me  :dizzy:
  •  
    โพสต์นี้ได้รับคำขอบคุณจาก: thanapol.w, NattakornC