本文介绍了工作表和VBA中UDF的不同结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在尝试使用 StrCmpLogicalW函数在MS Excel中实现Normal,或"Windows文件夹和文件名",或字母数字排序。 我声明了UDF  ; NormalCmp: 声明函数NormalCmp Lib" shlwapi.dll"别名"StrCmpLogicalW" (ByVal s1 As String,ByVal s2 As String)As Long 这是问题:从工作表调用时: a9 a81 = normalcmp(A16,B16) 它返回(-1) - 正确的结果,"a9"<""" a81" 但使用VBA时: 子测试() MsgBox NormalCmp(" a9"," a81") End Sub 它会返回1,但是它会使用相同的函数和参数。解决方案 I'm trying to implement Normal, or "Windows folder and filename", or alphanumerical sorting in MS Excel by using StrCmpLogicalW function.I declared UDF NormalCmp: Declare Function NormalCmp Lib "shlwapi.dll" Alias "StrCmpLogicalW" (ByVal s1 As String, ByVal s2 As String) As LongHere is the problem: when called from Worksheet:a9 a81 =normalcmp(A16,B16)it returns (-1) - right result, "a9"<"a81"but when using VBA:Sub test() MsgBox NormalCmp("a9", "a81")End Subit returns 1, although it uses the same function and parameters. 解决方案 这篇关于工作表和VBA中UDF的不同结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-27 00:00