 |
ช่วยผมสร้างแปลงจากภาษา VB เป็นภาษา php หน่อยครับหรือ javascript ก้อได้ |
|
 |
|
|
 |
 |
|
Code (VB.NET)
Dim A, B, C, D, E, F, G, H, I, J As Integer
A = digit(1) + digit(3) + digit(5) + digit(7) + digit(9) + digit(11)
B = IIf((digit(2) * 2) > 9, digit(2) * 2 - 9, digit(2) * 2)
Tag : PHP, JavaScript, CakePHP
|
|
 |
 |
 |
 |
Date :
2012-07-26 20:22:58 |
By :
NattawutSe |
View :
1105 |
Reply :
9 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ประมาณนี้ครับ
Code (PHP)
$A = ctype_digit(1) + ctype_digit(3) + ctype_digit(5) + ctype_digit(7) + ctype_digit(9) + ctype_digit(11);
if((ctype_digit(2) * 2) > 9)
{
$B = ctype_digit(2) * 2 - 9;
}
else
{
$B = ctype_digit(2) * 2;
}
|
 |
 |
 |
 |
Date :
2012-07-27 05:45:41 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากครับ
|
 |
 |
 |
 |
Date :
2012-07-27 10:20:49 |
By :
NattawutSe |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (VB.NET)
Public Shared Function CheckSumDigit(ByVal id As String) As Integer
'// Check input data length
If Len(id) <> 3 Then
Return 0
End If
Dim digit(3) As Integer
Dim z As Integer
For z = 1 To 3
digit(z) = id.Substring(z - 1, 1)
Next
Dim A, B, C, D, E, F, G, H, I, J As Integer
A = digit(1) + digit(3) + digit(5) + digit(7) + digit(9) + digit(11)
B = IIf((digit(2) * 2) > 9, digit(2) * 2 - 9, digit(2) * 2)
C = IIf((digit(4) * 2) > 9, digit(4) * 2 - 9, digit(4) * 2)
D = A + B + C
E = H Mod 3
F = IIf(3 - E = 3, 0, 3 - E)
Return F
End Function
อันนี้แบบเต็มครับช่วยแก้เป็นphpให้หน่อยนะครับ ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2012-07-27 12:50:07 |
By :
NattawutSe |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$$$$$$$$$$$$$$$$$$$$$$$$$$$$
|
ประวัติการแก้ไข 2012-07-28 11:48:31
 |
 |
 |
 |
Date :
2012-07-27 15:08:14 |
By :
NattawutSe |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองใส่รหัสที่ผมใช้งานจริงดูนะครับ
5316250220303
|
 |
 |
 |
 |
Date :
2012-07-27 15:18:17 |
By :
NattawutSe |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันก็ยัง WRONG อยู่
จริง ๆ มันต้องถูกใช่ป่ะ รอหน่อย ๆ คงมีเทพ ๆ มาต่อ ผมจนมุมล่ะ 
|
 |
 |
 |
 |
Date :
2012-07-27 15:21:26 |
By :
apisitp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คร็าบบบบบบบบบบบบบบบบบบบบบบบบบ
|
 |
 |
 |
 |
Date :
2012-07-27 15:22:03 |
By :
NattawutSe |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|