在VB中如何设计一个程序:只要输入第一个条形码和最后一个条形码,就能将这当中的所有条形码保存到数据库
在VB中如何设计一个程序:只要输入第一个条形码和最后一个条形码,就能将这当中的所有条形码保存到数据库中?这条形码是34进制,当中含有0到9,字母A到Z,当中没有i和o请高...
在VB中如何设计一个程序:只要输入第一个条形码和最后一个条形码,就能将这当中的所有条形码保存到数据库中?这条形码是34进制,当中含有0到9,字母A到Z,当中没有i和o
请高手帮忙!!! 展开
请高手帮忙!!! 展开
展开全部
Private Function DecToX(ByVal Value As Long, ByVal X As Integer) As String
Dim s As String
s = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ"
Dim rtn As String
Dim m As Integer
Do Until Value = 0
m = Value Mod X
rtn = Mid(s, m + 1, 1) & rtn
Value = Value \ X
Loop
If Len(rtn) = 0 Then rtn = "0"
DecToX = rtn
End Function
'X进制转为10进制
Private Function XToDec(ByVal Value As String, ByVal X As Integer) As Long
Dim s As String
s = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ"
Value = UCase(Value)
Dim rtn As Long
Dim i As Integer
Dim m As Integer
Dim b As Boolean
For i = Len(Value) To 1 Step -1
m = InStr(s, Mid(Value, i, 1)) - 1
If m < 0 Or m >= X Then b = True
rtn = rtn + m * X ^ (Len(Value) - i)
Next
If b Then MsgBox "你的输入的数据并不合法,转换的结果将错误!"
XToDec = rtn
End Function
'使用:如下手写代码你自己看着办了
dim rs as new adodb.recordset
rs.open "select bcode from tb ",cnn,3,3 '打开数据表
dim C1 as long ,C2 as long
c1=xtodec("你的开始条码",34)
c2=xtodec("你的结束条码",34)
dim i as long
dim s as string
for i = c1 to c2
s=dextox(i,34) '这是你要的条码结果
s=right("0000000000" & s ,9) '条码定长的不足9位前面补0,
'上面的S就是你要的结果
rs.addnew
rs(0)=s
rs.update
'上面代码保存到数据表中,
next
rs.close
Dim s As String
s = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ"
Dim rtn As String
Dim m As Integer
Do Until Value = 0
m = Value Mod X
rtn = Mid(s, m + 1, 1) & rtn
Value = Value \ X
Loop
If Len(rtn) = 0 Then rtn = "0"
DecToX = rtn
End Function
'X进制转为10进制
Private Function XToDec(ByVal Value As String, ByVal X As Integer) As Long
Dim s As String
s = "0123456789ABCDEFGHJKLMNPQRSTUVWXYZ"
Value = UCase(Value)
Dim rtn As Long
Dim i As Integer
Dim m As Integer
Dim b As Boolean
For i = Len(Value) To 1 Step -1
m = InStr(s, Mid(Value, i, 1)) - 1
If m < 0 Or m >= X Then b = True
rtn = rtn + m * X ^ (Len(Value) - i)
Next
If b Then MsgBox "你的输入的数据并不合法,转换的结果将错误!"
XToDec = rtn
End Function
'使用:如下手写代码你自己看着办了
dim rs as new adodb.recordset
rs.open "select bcode from tb ",cnn,3,3 '打开数据表
dim C1 as long ,C2 as long
c1=xtodec("你的开始条码",34)
c2=xtodec("你的结束条码",34)
dim i as long
dim s as string
for i = c1 to c2
s=dextox(i,34) '这是你要的条码结果
s=right("0000000000" & s ,9) '条码定长的不足9位前面补0,
'上面的S就是你要的结果
rs.addnew
rs(0)=s
rs.update
'上面代码保存到数据表中,
next
rs.close
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询