Home > Software engineering >  Excel vba parsing logic character
Excel vba parsing logic character

Time:09-24

Such as EXCEL form 4 XF 26 & amp; CJ2 & amp; KA1 & amp; VRG& 4 aa/4 aw/4 fa - KU1/KU3 represents 4 XF and contains 26 CJ2 and contains KA1 and contains VRG and contains 4 aa and contains 4 fa but does not contain KU1 does not contain KU3, whether there is method in the VBA can parse, the string on the logical character? For help?



For example A& B& C - D/E so I judge A is true, is true, B C is true, not D is true, not E is true then I this is is true
To judge A, B, C, D, E is on the other table, it contains A, contain is true



CodePudding user response:

Can try call VBScript Eval function,

CodePudding user response:

reference 1st floor zhao4zhong1 response:
can try calling Eval function of VBScript,

Fyi:
 Function RegExpN (PTN, TXT, n) As String 
'the Debug. Print "[" + RegExpN (" [012] {8}", "mno_if22220101_and11000011_or00111100_xor10101010. TXT", 1) + "] "
'[22220101]
'the Debug. Print "[" + RegExpN (" [012] {8}", "mno_if22220101_and11000011_or00111100_xor10101010. TXT", 2) + "] "
'[11000011]
'the Debug. Print "[" + RegExpN (" [012] {8}", "mno_if22220101_and11000011_or00111100_xor10101010. TXT", 3) + "] "
'[00111100]
'the Debug. Print "[" + RegExpN (" [012] {8}", "mno_if22220101_and11000011_or00111100_xor10101010. TXT", 4) + "] "
'[10101010]
'the Debug. Print "[" + RegExpN (" [012] {8}", "mno_if22220101_and11000011_or00111100_xor10101010. TXT", 5) + "] "
'[]
'the Debug. Print "[" + RegExpN (" [a-z] + (\ d +)/_.", "mno_if22220101_and11000011_or00111100_xor10101010. TXT", 4) + "] "
'[xor10101010]
'the Debug. Print "[" + RegExpN (" [a-z] + (\ d +)/_.", "mno_if22220101_and11000011_or00111100_xor10101010. TXT", 4.1) + "] "
'[10101010]
'the Debug. Print "[" + RegExpN (" & lt; abc> (. *) & lt;/abc>", "& lt; html> & lt; ab> AB & lt; abc> ABC & lt; Chinese characters/abc> & lt;/html>", 1) + "] "
'[& lt; abc> ABC & lt; Chinese characters/abc>]
'the Debug. Print "[" + RegExpN (" & lt; abc> (. *) & lt;/abc>", "& lt; html> & lt; ab> AB & lt; abc> ABC & lt; Chinese characters/abc> & lt;/html>", 1.1) + "] "
'[ABC] Chinese characters
Dim RTNSTR As String
Dim codestr As String
RTNSTR=""
With ScriptControl1
'Set the script language (VBScript is the default).
. Language="VBScript"
'Set the UI interaction (TRUE is the default).
. AllowUI=True
'Copy the script to the control.
'-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Codestr=""
Codestr=codestr + "Function RegExpTest (patrn STRNG, ns)" + vbCrLf
Codestr=codestr + "Dim regEx, Match, Matches, RetStr, ii" + vbCrLf
Codestr=codestr + "Dim nn, ss" + vbCrLf
Codestr=codestr + nn="fix (ns)" + vbCrLf
Codestr=codestr + "if nn=ns then" + vbCrLf
Codestr=codestr + "ss=1" + vbCrLf
Codestr=codestr + "else" + vbCrLf
Codestr=codestr + "ss=(ns - nn) * 10-1" + vbCrLf
Codestr=codestr + "end if" + vbCrLf
Codestr=codestr + "Set the regEx=New RegExp" + vbCrLf
Codestr=codestr + "regEx Pattern=patrn" + vbCrLf
Codestr=codestr + "regEx IgnoreCase=True" + vbCrLf
Codestr=codestr + "regEx. Global=True" + vbCrLf
Codestr=codestr + "Set Matches=regEx. Execute (STRNG)" + vbCrLf
Codestr=codestr + 2="0" + vbCrLf
Codestr=codestr + "For Each Match Matches in" + vbCrLf
Codestr=codestr + 2=2 + 1 "" + vbCrLf
Codestr=codestr + "if ii=nn then" + vbCrLf
Codestr=codestr + "if ss=1 then" + vbCrLf
Codestr=codestr + "RetStr=Match. The Value" + vbCrLf
Codestr=codestr + "else" + vbCrLf
Codestr=codestr + "RetStr=Match. SubMatches (ss)" + vbCrLf
Codestr=codestr + "end if" + vbCrLf
Codestr=codestr + "exit for" + vbCrLf
Codestr=codestr + "end if" + vbCrLf
Codestr=codestr + "Next" + vbCrLf
Codestr=codestr + "RegExpTest=RetStr" + vbCrLf
Codestr=codestr + "Set the regEx=Nothing" + vbCrLf
Codestr=codestr + "End the Function" + vbCrLf
'-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
. AddCode codestr
Dim oMod As Object
The Set oMod=. Modules (GlobalModule)
RTNSTR=oMod. Run (" RegExpTest PTN, TXT, n)
The Set oMod=Nothing
End With
RegExpN=RTNSTR
End the Function
  •  Tags:  
  • VBA
  • Related