vb6正则表达式 Replace的使用问题
发布网友
发布时间:2022-05-09 22:45
我来回答
共1个回答
热心网友
时间:2022-04-23 06:57
很多时间不用正则还快点,不清楚你的数据具体格式是否都形如Tree:1-100,如果都是这样,那可以用比如
Public Function PadLeft(ByVal s As String, ByVal i As Integer, ByVal c As String)
If i > LenB(s) Then
PadLeft = String(i - LenB(StrConv(s, vbFromUnicode)), c) & s
Else
PadLeft = s
End If
End Function
Private Sub Command1_Click()
Dim a As String
Dim re As Object
a = "Tree:1-500"
temp = Split(a, ":")
temp = Split(temp(1), "-")
MsgBox "Tree:" & PadLeft(temp(0), 4, "0") & "-" & PadLeft(temp(1), 4, "0")
End Sub