|
Function ZG(NumBer As String) As String
Dim a As String
If Mid(NumBer, 1, 2) <> "ZJ" Then
If Len(NumBer) = 5 Then
a = "ZJ" & NumBer
ElseIf Len(NumBer) < 5 Then
a = "ZJ" & Format(NumBer, "0aaaa")
ElseIf Len(NumBer) > 5 Then
MsgBox "无此编号", , "至佳管理"
a = Null
End If
Else
If Len(Mid(NumBer, 3, 7)) = 5 Then
a = NumBer
ElseIf Len(Mid(NumBer, 3, 7)) < 5 Then
a = "ZJ" & Format(Mid(NumBer, 3, 7), "0aaaa")
ElseIf Len(Mid(NumBer, 3, 7)) > 5 Then
MsgBox "无此编号", , "至佳管理"
a = Null
End If
End If
ZG = a
End Function
这段代码,当我输入全数字时都很正常,如
2504
其效果为:ZJ02504
可是当我输入2A03
其确是为:ZJ2A03
请问怎样才能使其效果为:ZJ02A03
|
|