Excel VBA不寫程式就不是打字員🙃,巨集對於一個打字員來說…
真的不夠用,用起來非常無感,對於現代的打字員來說,太多不適應,
以上是個人覺得問題比較大的部份,但現代程式語言過多,VBA只能說是過時,
早期古代還行,對於現代視窗介面…那還真的不OK,還不如用JAVA C# C++等..。
使用JSON模式來整理資料可行❓答案是可行的✅
Dictionary Method
ArrayLiST Method
.NET3.5 版本才能使用 ArrayList VBA 變數定義範例
Variable 1 2 3 4 5 6 7 8 9 10 11 12 Dim iNumber% 'Integer Dim lAverage& 'Long Dim sngTotal! 'Single Dim dbTotal# 'Double Dim cProfit@ 'Currency Dim sFirstName$ 'String Dim llDiscount^ 'LongLong on 64 bit Dim a() As Byte, u&, j&, s&, n&: Dim ArrString() As String, Rows As Long, Arrays() As Variant
VarType 1 2 3 Dim myVariant myVariant = 10# Debug.Print VarType(myVariant) = vbDouble --> return True
TypeName 1 2 3 Dim myVariant myVariant = 10# Debug.Print TypeName(myVariant) --> Double
CRUD Create 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Dim Json As Object Set Json = CreateObject("Scripting.Dictionary") If Json.Exists("Key-1") = False then # 建立 ArrayList 物件 Dim ArrList As Object Set ArrList = CreateObject("System.Collections.ArrayList") Json.Add "Key-1", ArrayList End If Json("Key-1").Add "John" Json("Key-1").Add "Leo"
Read 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Debug.Print Json("Key-1")(0) --> John Debug.Print Json("Key-1")(1) --> Leo ' Loop Dim x& For x = 0 To (Json("Key-1").Count -1) Debug.Print Json("Key-1")(x) Next x Dim item As Variant For Each item In coll Debug.Print Json("Key-1")(item) Next item
Update 1 2 3 Json("Key-1")(0) = "Bob" Json("Key-1").Insert 0, "Andy"
Delete 1 2 3 Json("Key-1").Remove("Andy"); ' OR Json("Key-1").RemoveAt(1);