Skip to content
This repository was archived by the owner on Apr 14, 2025. It is now read-only.

Commit 802218e

Browse files
authored
Merge pull request #2 from marmeleiro/v1.3.0
配列の拡張判定方法変更、リッチエディタのタグ取り修正
2 parents 9fa2577 + 9a8ff6b commit 802218e

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed

example/example.xlsm

-462 Bytes
Binary file not shown.

src/kintoneDataReaderforVBA.cls

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Attribute VB_Creatable = False
88
Attribute VB_PredeclaredId = False
99
Attribute VB_Exposed = False
1010
' -----------------------------------------------------------------------
11-
' kintoneDataReaderforVBA v1.2.0
11+
' kintoneDataReaderforVBA v1.3.0
1212
' -Dictionary.cls と JsonConverter.bas のインポートが必要です。下記から取得してください。
1313
'   Dictionary.cls:v1.4.1で動作確認
1414
'   https://github.com/VBA-tools/VBA-Dictionary
@@ -497,11 +497,7 @@ Public Function RecordFields(Optional ByVal existsPropOnly As Boolean = True) As
497497
isTarget = True
498498
End If
499499
If isTarget Then
500-
If Sgn(resultFields) = 0 Then
501-
ReDim resultFields(0)
502-
Else
503-
ReDim Preserve resultFields(UBound(resultFields) + 1)
504-
End If
500+
Call incrimentArray(resultFields)
505501
resultFields(UBound(resultFields)) = CStr(f)
506502
End If
507503
Next
@@ -603,11 +599,7 @@ Public Function RecordArray(Optional ByVal addFieldLabel As Boolean = True, Opti
603599
fieldsOrg = Me.RecordFields(existsPropOnly)
604600
For k = LBound(fieldsOrg) To UBound(fieldsOrg)
605601
If Me.FieldType(CStr(fieldsOrg(k))) <> "SUBTABLE" Then
606-
If Sgn(fields) = 0 Then
607-
ReDim fields(0)
608-
Else
609-
ReDim Preserve fields(UBound(fields) + 1)
610-
End If
602+
Call incrimentArray(fields)
611603
fields(UBound(fields)) = fieldsOrg(k)
612604
End If
613605
Next
@@ -718,9 +710,12 @@ Public Function RemoveTags(ByVal str As String, ByVal typ As RemoveTagsEnum) As
718710
Set doc = CreateObject("htmlfile")
719711
Call doc.write(str)
720712
Dim retStr As String
721-
retStr = doc.FirstChild.innerText
722-
If typ = RemoveTagsEnum.RemoveAll Then
723-
retStr = Replace(Replace(Replace(retStr, vbCr, ""), vbCrLf, ""), vbLf, "")
713+
If doc.FirstChild Is Nothing Then
714+
Else
715+
retStr = doc.FirstChild.innerText
716+
If typ = RemoveTagsEnum.RemoveAll Then
717+
retStr = Replace(Replace(Replace(retStr, vbCr, ""), vbCrLf, ""), vbLf, "")
718+
End If
724719
End If
725720
RemoveTags = retStr
726721
End If
@@ -1102,6 +1097,25 @@ Private Function getErrorMessage(ByVal num As KTN_VBA_EXCEPTION) As String
11021097
End Select
11031098
getErrorMessage = result
11041099
End Function
1100+
1101+
''' <summary>
1102+
''' incrimentArray
1103+
''' </summary>
1104+
''' <param name="rArray"></param>
1105+
Private Sub incrimentArray(ByRef rArray() As String)
1106+
1107+
On Error GoTo ErrHandler
1108+
ReDim Preserve rArray(UBound(rArray) + 1)
1109+
1110+
Exit Sub
1111+
1112+
ErrHandler:
1113+
If Err.Number = 9 Then
1114+
ReDim rArray(0)
1115+
Else
1116+
Err.Raise (Err.Number)
1117+
End If
1118+
End Sub
11051119
Private Sub Class_Initialize()
11061120
Me.Lang = ""
11071121
Me.IsName = True

0 commit comments

Comments
 (0)