|
如果数据规范,则提取数据模块如下
- Sub TextTest()
- Dim intLessThan As Integer, intGreaterThan As Integer
- Dim intLeftParentheses As Integer, intRigftParentheses As Integer
- Dim strOldText As String, strNewText1 As String, strNewText2 As String, strNewText3 As String
- strOldText = "R816,R861,R897" & _
- "<0341012315(1/10W 10ohm F 0603)>" & _
- "<0341012332(1/11W 10ohm F 0603)>" & _
- "<0341012333(1/12W 10ohm F 0603)>" & _
- "<0341012334(1/13W 10ohm F 0603)>" & _
- "<0341012335(1/14W 10ohm F 0603)>"
- strNewText = Replace(strOldText, "<", "")
- n = (Len(strOldText) - Len(strNewText))
- For m = 1 To n
- intLessThan = InStr(intGreaterThan + 1, strOldText, "<", 1)
- If intLessThan <> 0 Then intGreaterThan = InStr(intLessThan, strOldText, ">")
- intLeftParentheses = InStr(intRigftParentheses + 1, strOldText, "(", 1)
- If intLeftParentheses <> 0 Then intRigftParentheses = InStr(intLeftParentheses, strOldText, ")")
- If intGreaterThan <> 0 Then
- strNewText2 = Mid(strOldText, intLessThan + 1, intLeftParentheses - 1 - intLessThan)
- strNewText3 = Mid(strOldText, intLeftParentheses + 1, intRigftParentheses - 1 - intLeftParentheses)
- End If
- If m = 1 Then strNewText1 = Left(strOldText, intLessThan - 1)
- Debug.Print strNewText1, strNewText2, strNewText3, "S"
- Next
- End Sub
复制代码 该模块建议写成函数形式,以dao或adodb方法循环记录集到字段【零件位置】时调用。
该代码没有经过数据调试,仅仅是一些思路而已。
水平有限,仅供参考,请笑纳!
|
|