Option Explicit
Public Sub TestMe()
Debug.Print CompareMe("ABC-DEF", "DEF-ABC")
Debug.Print CompareMe("ABC-DEF", "DEF-AAC")
End Sub
Public Function CompareMe(strCompareA As String, strCompareB As String, Optional strDelim = "-")
Dim arrA As Variant
Dim arrB As Variant
arrA = Split(strCompareA, strDelim)
arrB = Split(strCompareB, strDelim)
CompareMe = (arrA(0) = arrB(1) And arrA(1) = arrB(0))
End Function
Option Explicit
Public Sub TestMe()
Debug.Print strReverseOrder("ABC-DEF-GHI")
Debug.Print strReverseOrder("ABC-DEF") = "DEF-ABC"
End Sub
Public Function strReverseOrder(strToReverse As String, Optional strDelim = "-")
Dim strWorking As String
Dim arrWorking() As String
Dim lngCounter As Long
Dim strAnswer As String
strWorking = StrReverse(strToReverse)
arrWorking = Split(strWorking, strDelim)
For lngCounter = LBound(arrWorking) To UBound(arrWorking)
strAnswer = IIf(lngCounter = LBound(arrWorking), vbNullString, strAnswer & strDelim) & StrReverse(arrWorking(lngCounter))
Next lngCounter
strReverseOrder = strAnswer
End Function
4条答案
按热度按时间kqlmhetl1#
的数据
公式是这样的
字符串
aemubtdh2#
有时,但只是有时,(特色 manchmal aber努尔manchmal)你可能会幸运地发布这样的问题得到回答:
字符串
检查
TestMe
sub,它会在控制台中打印结果。此外,this is an interview algorithm question, asked by Google。这是一个通用的工作答案- * 反转整个字符串,然后按单词拆分,并反转每个单词 *。这是如何使用this is an interview algorithm question, asked by Google:
型
uhry853o3#
以下为我工作:
字符串
hec6srdp4#
假设这是
A1
,将其放入B1
:=IF(A1="ABC-DEF","DEF-ABC",A1)
中。向下拖动以填充。