2014年12月11日 星期四
VBNET 自然憑證簡易驗證
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As String = "AB01234567891234"
MessageBox.Show(chk_card(a))
End Sub
Public Overloads Function chk_card(ByVal card_code As String) As Boolean
Dim chk_yn As Boolean = False
Try
Dim str_g As String = ""
Dim y As Integer = 0
For i As Integer = 1 To 16
str_g = Mid(card_code, i, 1)
Select Case i
Case 1 To 2
If Asc(str_g) > 90 Or Asc(str_g) < 65 Then
y = 1
Exit For
End If
Case 3 To 16
If Asc(str_g) > 57 Or Asc(str_g) < 48 Then
y = 1
Exit For
End If
End Select
Next
If y = 0 Then
chk_yn = True
End If
Return chk_yn
Catch ex As Exception
Return chk_yn
End Try
End Function
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言