'按楼上的思路写了点代码,不敢保证是最简单的
Private Sub Command1_Click()
Dim strData(0 To 1) As String
Dim strTemp() As String
Dim i As Long, j As Long
strData(0) = "AVB4-1"
strData(1) = "AB5-36"
For i = 0 To UBound(strData)
strTemp = Split(strData(i), "-")
strTemp(1) = Format(strTemp(1), "000")
For j = Len(strTemp(0)) To 1 Step -1
If IsNumeric(Mid(strTemp(0), j, 1)) = False Then
strTemp(0) = Left(strTemp(0), j) & Format(Val(Right(strTemp(0), Len(strTemp(0)) - j)), "00")
Exit For
End If
Next
strData(i) = strTemp(0) & "-" & strTemp(1)
Debug.Print strData(i)
Next
Private Sub Command2_Click()
MsgBox trans("AB5-36") & vbCrLf & trans("AvB4-1")
End Sub
Function trans(ByVal x As String) As String
Dim temp As String
temp = Left(x, InStr(x, "-")) & " "
Mid(temp, Len(temp) - 2) = "0" & Trim(Right(temp, 3))
trans = Format(Mid(x, InStr(x, "-") + 1), "000")
trans = temp & trans
End Function