sinhatexcel
Thành viên mới 

			
		- Tham gia
 - 7/12/10
 
- Bài viết
 - 5
 
- Được thích
 - 0
 

Mình xin lỗi các bạn.Đây phần demo của mình.
Khi người dùng chọn sự kiện DropButtonClick trên Combobox thì dữ liệu trong combobox hiển thị theo thứ tự A->Z.
Cám ơn các bạn!
Function Sort1DArray(ByVal Arr, Optional ByVal isText As Boolean = False, Optional ByVal isDESC As Boolean = False)
  Dim sCommand As String
  sCommand = "('" & Join(Arr, vbBack) & "').split('" & vbBack & "').sort("
  If isText Then
    sCommand = sCommand & ")"
  Else
    sCommand = sCommand & "function(a,b){return (a-b)})"
  End If
  If isDESC Then sCommand = sCommand & ".reverse()"
  sCommand = sCommand & ".join('" & vbBack & "')"
  With CreateObject("MSScriptControl.ScriptControl")
    .Language = "JavaScript"
    Sort1DArray = Split(.Eval(sCommand), vbBack)
  End With
End Function
	Chào thầy @ndu96081631, dù bài viết đã 6 năm rồi, không biết thầy đã có giải pháp nào hoặc nâng cấp function này để có thể sort theo tiếng việtDùng hàm này để sort mảng 1 chiều nhé:
Lưu ý là không sort tiếng Việt Unicode đâu nhaPHP:Function Sort1DArray(ByVal Arr, Optional ByVal isText As Boolean = False, Optional ByVal isDESC As Boolean = False) Dim sCommand As String sCommand = "('" & Join(Arr, vbBack) & "').split('" & vbBack & "').sort(" If isText Then sCommand = sCommand & ")" Else sCommand = sCommand & "function(a,b){return (a-b)})" End If If isDESC Then sCommand = sCommand & ".reverse()" sCommand = sCommand & ".join('" & vbBack & "')" With CreateObject("MSScriptControl.ScriptControl") .Language = "JavaScript" Sort1DArray = Split(.Eval(sCommand), vbBack) End With End Function