LoginSignup
2
1

More than 5 years have passed since last update.

XojoでFinderと同じ文字列照合

Last updated at Posted at 2014-12-29

XojoでFinderと同じ文字列照合をするメソッドです。


Function FinderCompare(str1 as String, str2 as String) As Integer

  Declare function localizedStandardCompare lib "Cocoa" selector "localizedStandardCompare:" (s1 as CFStringRef, s2 as CFStringRef) as Integer

  Return localizedStandardCompare(str1, str2)

End Function

戻り値は、-1、0、1の3つ。
* str1 < str2 … -1
* str1 = str2 … 0
* str1 > str2 … 1

これを利用して、ListBoxのCompareRowsイベントに以下のように書いておくと、Finderと同等のソートをするようになりますよ。

  result = FinderCompare( me.Cell(row1,column), me.cell(row2,column) )

  Return True

FinderSort.png

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1