ใช้หลักการค้นหาจุดทศนิยม แล้วก็ตัดเอาตัวเลขหน้าจุด หลังจุด มาแปลงเป็นตัวเลข ทำแบบบ้าน แบบง่ายกว่านี้ทำไม่เป็น
Option Compare Database
Function chkjood(tjood) As String
Dim T1, L1 As Integer
Dim Fn, Ln As String
T1 = InStr(tjood, ".")
L1 = Len(tjood)
If IsNumeric(tjood) Then
If T1 = 1 Then
chkjood = Round("0" & tjood, 3)
Else
If T1 = L1 Then
chkjood = Round(Replace(tjood, ".", ""), 3)
Else
chkjood = Round(tjood, 3)
End If
End If
Else
If T1 = 1 And L1 = 1 Then
chkjood = ""
ElseIf T1 = 1 And L1 > 1 Then
If IsNumeric(Mid(tjood, T1 + 1, 3)) Then
chkjood = "0." & Mid(tjood, T1 + 1, 3)
ElseIf IsNumeric(Mid(tjood, T1 + 1, 2)) Then
chkjood = "0." & Mid(tjood, T1 + 1, 2)
ElseIf IsNumeric(Mid(tjood, T1 + 1, 1)) Then
chkjood = "0." & Mid(tjood, T1 + 1, 1)
Else
chkjood = ""
End If
ElseIf T1 > 1 And L1 > 1 Then
If IsNumeric(Left(tjood, T1 - 1)) Then
Fn = Left(tjood, T1 - 1)
Else
If T1 = 2 Then
If IsNumeric(Left(tjood, 1)) Then
Fn = Left(tjood, 1)
Else
Fn = ""
End If
ElseIf T1 = 3 Then
If IsNumeric(Mid(tjood, T1 - 1, 1)) Then
Fn = Mid(tjood, T1 - 1, 1)
Else
Fn = ""
End If
ElseIf T1 = 4 Then
If IsNumeric(Mid(tjood, T1 - 2, 2)) Then
Fn = Mid(tjood, T1 - 2, 2)
Else
Fn = ""
End If
ElseIf T1 = 5 Then
If IsNumeric(Mid(tjood, T1 - 3, 3)) Then
Fn = Mid(tjood, T1 - 3, 3)
Else
Fn = ""
End If
ElseIf T1 = 6 Then
If IsNumeric(Mid(tjood, T1 - 4, 4)) Then
Fn = Mid(tjood, T1 - 4, 4)
Else
Fn = ""
End If
ElseIf T1 = 7 Then
If IsNumeric(Mid(tjood, T1 - 5, 5)) Then
Fn = Mid(tjood, T1 - 5, 5)
Else
Fn = ""
End If
ElseIf T1 = 8 Then
If IsNumeric(Mid(tjood, T1 - 6, 6)) Then
Fn = Mid(tjood, T1 - 6, 6)
Else
Fn = ""
End If
ElseIf T1 = 9 Then
If IsNumeric(Mid(tjood, T1 - 7, 7)) Then
Fn = Mid(tjood, T1 - 7, 7)
Else
Fn = ""
End If
ElseIf T1 = 10 Then
If IsNumeric(Mid(tjood, T1 - 8, 8)) Then
Fn = Mid(tjood, T1 - 8, 8)
Else
Fn = ""
End If
End If
End If
If IsNumeric(Mid(tjood, T1 + 1, 3)) Then
chkjood = Fn & "." & Mid(tjood, T1 + 1, 3)
ElseIf IsNumeric(Mid(tjood, T1 + 1, 2)) Then
chkjood = Fn & "." & Mid(tjood, T1 + 1, 2)
ElseIf IsNumeric(Mid(tjood, T1 + 1, 1)) Then
chkjood = Fn & "." & Mid(tjood, T1 + 1, 1)
Else
chkjood = Fn
End If
End If
End If
End Function
------------------------------------------------------------------------------
ใส่สูตรในคิวรี่ =IIf(chkjood([ฟิลด์ข้อมูล])="",Null,CDbl(chkjood([ฟิลด์ข้อมูล])))