它比看起来更为复杂。 如果我不错的话,每小时加一米可以有Max7的操作员和1名操作员。 在这种情形下,获得“K”和“M”价值确实变得复杂。 —— Siddharth Rout 33mins before
Building on my comment in duffymo s post
This snapshot shows the different combinations that “kx + m” can have
如前所述,实现你想要的东西非常复杂。 这里是我的feebletries,目前仅提取“K”。 <><>>> 这部法律绝无任何区别。 此外,我没有用不同的假设情景测试该守则,因此可能与其他人失败。 然而,这给你带来了如何解决这一问题的公平想法。 你们将不得不夸张,以取得你想要的准确结果。
http://www.ohchr.org。 (我正在测试该法典中的7个可能的组合。) 它为这7项工作而努力,但可能会/会因他人而失败。
Option Explicit
Sub Sample()
Dim StrCheck As String
Dim posStar As Long, posBrk As Long, pos As Long, i As Long
Dim strK As String, strM As String
Dim MyArray(6) As String
MyArray(0) = "-k*(-x)+(-m)*(-2)"
MyArray(1) = "-k*x+(-m)*(-2)"
MyArray(2) = "-k(x)+(-m)*(-2)"
MyArray(3) = "-k(x)+(-m)(-2)"
MyArray(4) = "-kx+m"
MyArray(5) = "kx+m"
MyArray(6) = "k(x)+m"
For i = 0 To 6
StrCheck = MyArray(i)
Select Case Left(Trim(StrCheck), 1)
Case "+", "-"
posBrk = InStr(2, StrCheck, "(")
posStar = InStr(2, StrCheck, "*")
If posBrk > posStar Then <~~ "-k*(-x)+(-m)*(-2)"
pos = InStr(2, StrCheck, "*")
If pos <> 0 Then
strK = Mid(StrCheck, 1, pos - 1)
Else
strK = Mid(StrCheck, 1, posBrk - 1)
End If
ElseIf posBrk < posStar Then <~~ "-k(-x)+(-m)*(-2)"
pos = InStr(2, StrCheck, "(")
strK = Mid(StrCheck, 1, pos - 1)
Else <~~ "-kx+m"
~~> In such a case I am assuming that you will never use
~~> a >=2 letter variable
strK = Mid(StrCheck, 1, 2)
End If
Case Else
posBrk = InStr(1, StrCheck, "(")
posStar = InStr(1, StrCheck, "*")
If posBrk > posStar Then <~~ "k*(-x)+(-m)*(-2)"
pos = InStr(1, StrCheck, "*")
If pos <> 0 Then
strK = Mid(StrCheck, 1, pos - 2)
Else
strK = Mid(StrCheck, 1, posBrk - 1)
End If
ElseIf posBrk < posStar Then <~~ "k(-x)+(-m)*(-2)"
pos = InStr(1, StrCheck, "(")
strK = Mid(StrCheck, 1, pos - 2)
Else <~~ "kx+m"
~~> In such a case I am assuming that you will never use
~~> a >=2 letter variable
strK = Mid(StrCheck, 1, 1)
End If
End Select
Debug.Print "Found " & strK & " in " & MyArray(i)
Next i
End Sub
<>SNAPSHOT
这不是一件好事,但我希望这能让你们走上正确的道路。