Private Sub btnFind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFind.Click
Dim conStr As String = "Data Source=.\SQLEXPRESS;Initial Catalog=TblUser;Integrated Security=True"
Dim conn As New SqlConnection(conStr)
Dim Sql As String
Dim cmd As SqlCommand
Dim reader As SqlDataReader
Sql = "select * from Car where license='" & txtFind.Text & "'"
Protected Function TungmanCheck(strCheck As String) As Boolean
Dim RegPatterm As String = "^[ท|ม]{1}+\w{1}+\s+\d{1,4}"
Dim Rgx As New System.Text.RegularExpressions.Regex(PokedexStartPattern)
Return If((Rgx.Match(strCheck) IsNot Nothing), True, False)
End Function
เวลาใช้
Code (VB.NET)
If TungmanCheck(txtLicen.Text) Then
MessageBox.Show("OK")
Else
MessageBox.Show("Incorrent format.")
End If
Date :
2010-08-13 15:15:24
By :
tungman
No. 4
Guest
โค๊ตผมเป้นแบบนี้คับ
Private Sub bntCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bntCheck.Click
Dim licen As String = txtLicen.Text
Dim objCmd As New SqlCommand
Dim strConn As String
Dim objReader As SqlDataReader
If licen = "" Then
MessageBox.Show("กรุณากรอก หมายเลขทะเบียนรถ")
ElseIf objReader.HasRows Then
MessageBox.Show("หมายเลขทะเบียนนี้ไม่สามารถใช้ได้")
Else
MessageBox.Show("หมายเลขทะเบียนนี้สามารถใช้ได้")
btnSave.Visible = True
End If
Protected Function TungmanCheck(strCheck As String) As Boolean
Dim RegPatterm As String = "^[ท|ม]{1}+\w{1}+\s+\d{1,4}"
Dim Rgx As New System.Text.RegularExpressions.Regex(RegPatterm)
Return If((Rgx.Match(strCheck) IsNot Nothing), True, False)
End Function
ว่าแต่เรียกใช้ function ไม่เป็นรึเปล่า แล้วก็ไม่ต้อง spam นะมันรกตา เห็นตั้งไป 3 กระทู้แล้ว
Dim fileName As String = dirquiz + "\Program Files\QuizP4"
MessageBox.Show(fileName)
Dim Rights As FileSystemRights
Dim Account As String = "Users"
Rights = FileSystemRights.FullControl
'set on dir itself
Dim AccessRule As New FileSystemAccessRule(Account, Rights, AccessControlType.Allow, PropagationFlags.NoPropagateInherit, AccessControlType.Allow)
Dim dInfo As New DirectoryInfo(fileName)
Dim dSecurity As DirectorySecurity = dInfo.GetAccessControl()
dSecurity.ModifyAccessRule(AccessControlModification.Set, AccessRule, True)
'Always allow objects to inherit on a directory
Dim iFlags As New InheritanceFlags()
iFlags = InheritanceFlags.ContainerInherit + InheritanceFlags.ObjectInherit
'Add Access rule for the inheritance
Dim AccessRule2 As New FileSystemAccessRule(Account, Rights, iFlags, PropagationFlags.InheritOnly, AccessControlType.Allow)
dSecurity.ModifyAccessRule(AccessControlModification.Add, AccessRule2, True)