thaicosmic.com

หนัง

วันเสาร์ที่ 22 กุมภาพันธ์ พ.ศ. 2557

ปวดหัวจุงเบย ทั้งคำนำหน้า ทั้งชื่อ ทั้งนามสกุลอยู่ใน Field เดียวกัน คำนำหน้าก็ไม่มีมาตรฐาน


Public Function OnlyLName(FullName) As String
    For i = Len(FullName) - 1 To 1 Step -1
            If Mid(FullName, i, 1) = " " Then
                    OnlyLName = Right(FullName, Len(FullName) - i)
                    Exit For
            End If
    Next
End Function

Public Function NoTitle(FullName) As String
If Left(FullName, 3) = "นาย" Then
    NoTitle = Right(FullName, Len(FullName) - 3)
ElseIf Left(FullName, 3) = "นาง" Then
    NoTitle = Right(FullName, Len(FullName) - 3)
ElseIf Left(FullName, 6) = "นางสาว" Then
    NoTitle = Right(FullName, Len(FullName) - 6)
ElseIf Left(FullName, 4) = "น.ส." Then
    NoTitle = Right(FullName, Len(FullName) - 4)
ElseIf Left(FullName, 3) = "นส." Then
    NoTitle = Right(FullName, Len(FullName) - 3)
ElseIf Left(FullName, 2) = "นส" Then
    NoTitle = Right(FullName, Len(FullName) - 2)
ElseIf Left(FullName, 7) = "เด็กชาย" Then
    NoTitle = Right(FullName, Len(FullName) - 7)
ElseIf Left(FullName, 3) = "ดช." Then
    NoTitle = Right(FullName, Len(FullName) - 3)
ElseIf Left(FullName, 4) = "ด.ช." Then
    NoTitle = Right(FullName, Len(FullName) - 4)
ElseIf Left(FullName, 3) = "ด.ช" Then
    NoTitle = Right(FullName, Len(FullName) - 3)
ElseIf Left(FullName, 2) = "ดช" Then
    NoTitle = Right(FullName, Len(FullName) - 2)
ElseIf Left(FullName, 8) = "เด็กหญิง" Then
    NoTitle = Right(FullName, Len(FullName) - 8)
ElseIf Left(FullName, 3) = "ดญ." Then
    NoTitle = Right(FullName, Len(FullName) - 3)
ElseIf Left(FullName, 4) = "ด.ญ." Then
    NoTitle = Right(FullName, Len(FullName) - 4)
ElseIf Left(FullName, 3) = "ด.ญ" Then
    NoTitle = Right(FullName, Len(FullName) - 3)
ElseIf Left(FullName, 2) = "ดญ" Then
    NoTitle = Right(FullName, Len(FullName) - 2)
End If
End Function

Public Function OnlyFName(FullName) As String
    For i = 1 To Len(FullName)
            If Mid(FullName, i, 1) = " " Then
                    OnlyFName = Left(FullName, i)
                    Exit For
            End If
    Next
End Function