Foxtable(狐表)用户栏目专家坐堂 → 车辆VIN码校验位算法


  共有3117人关注过本帖树形打印复制链接

主题:车辆VIN码校验位算法

帅哥哟,离线,有人找我吗?
wjl-se
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:771 积分:6382 威望:0 精华:0 注册:2011/12/1 14:47:00
车辆VIN码校验位算法  发帖心情 Post By:2015/10/20 11:44:00 [只看该作者]

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:车辆识别码vin校验位计算方法.rar

 

算法在附件中,百度得来,问题是水平太低,求老师帮忙写个代码,谢谢。


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/10/20 11:47:00 [只看该作者]

直接去拿例子的代码配上去。

 回到顶部
帅哥哟,离线,有人找我吗?
wjl-se
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:771 积分:6382 威望:0 精华:0 注册:2011/12/1 14:47:00
  发帖心情 Post By:2015/10/20 11:56:00 [只看该作者]

我能想到的办法是建数据表去查询,再计算,可能比较笨,有没有可能全写在代码里?


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/10/20 12:18:00 [只看该作者]

mark 车辆识别码

 

Dim q() As Integer = {8,7,6,5,4,3,2,10,1,9,8,7,6,5,4,3,2}
Dim v() As Integer = {0,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,1,2,3,4,5,7,9,2,3,4,5,6,7,8,9}
Dim w() As String = {0,1,2,3,4,5,6,7,8,9,"A","B","C","D","E","F","G","H","J","K","L","M","N","P","R","S","T","U","V","W","X","W","Z"}
Dim num As String = "UU6JA69691D713820"
Dim sum As Double = 0
For i As Integer = 0 To num.length - 1
    Dim s As String = num(i)
    sum += v(array.indexOf(w,s.ToUpper)) * q(i)
Next
Dim n9 As String = num(8)
sum = (sum - n9) Mod 11
msgbox(sum)

[此贴子已经被作者于2015/10/20 12:18:32编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
wjl-se
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:771 积分:6382 威望:0 精华:0 注册:2011/12/1 14:47:00
  发帖心情 Post By:2015/10/20 12:52:00 [只看该作者]

谢谢,非常感谢!

 回到顶部
帅哥哟,离线,有人找我吗?
wjl-se
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:771 积分:6382 威望:0 精华:0 注册:2011/12/1 14:47:00
  发帖心情 Post By:2015/10/20 13:30:00 [只看该作者]

红袍老师,还有一种特殊情况:

如果余数为10,校验码为字母X

比如:LFP83ACCXD1D99699,4楼的算法不灵了


 回到顶部
帅哥哟,离线,有人找我吗?
wjl-se
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:771 积分:6382 威望:0 精华:0 注册:2011/12/1 14:47:00
  发帖心情 Post By:2015/10/20 13:51:00 [只看该作者]

代码看了个大概,改了改就行了:

Dim q() As Integer = {8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2}
Dim v() As Integer = {0,1,2,3,4,5,6,7,8,9,1,2,3,4,5,6,7,8,1,2,3,4,5,7,9,2,3,4,5,6,7,8,9}
Dim w() As String = {0,1,2,3,4,5,6,7,8,9,"A","B","C","D","E","F","G","H","J","K","L","M","N","P","R","S","T","U","V","W","X","Y","Z"}
Dim num As String = "LFP83ACCXD1D99699"
Dim sum As Double = 0
For i As Integer = 0 To num.length - 1
    Dim s As String = num(i)
    sum += v(array.indexOf(w,s.ToUpper)) * q(i)
Next
Dim n9 As String = IIF(sum Mod 11 = 10, "X", sum Mod 11)
msgbox(n9)

[此贴子已经被作者于2015/10/20 15:03:09编辑过]

 回到顶部