Когда я запускаю этот код, он показывает диалоговое окно, в котором в строке For i = 0 To UBound(arffArray)
указано «Несоответствие типов»В чем проблема с моим кодом?
Public Function processFile()
Dim i, j, posRelation, temp, att, data, flag
Dim strRelation
Dim strAtt
Dim strData
strRelation = "@relation"
strAtt = "@attribute"
strData = "@data"
att = 0
data = 0
For i = 0 To UBound(arffArray)
If (InStr(arffArray(i), strRelation)) Then
temp = Replace(Mid(arffArray(i), 11, Len(arffArray(i))), "'", "")
RelationName = temp
ElseIf (InStr(arffArray(i), strAtt)) Then
flag = parseAtt(att, arffArray(i))
If (Not flag) Then
processFile = flag
Exit Function
End If
att = att + 1
ElseIf (InStr(arffArray(i), strData)) Then
data = readTheRest(i)
i = UBound(arffArray) 'end the loop
totalData = data
End If
Next
'get the list of class name
Dim tmpClassAttr
tmpClassAttr = attArray(1, UBound(attArray, 2))
For i = 0 To UBound(tmpClassAttr)
ReDim Preserve classArray(i)
classArray(i) = Trim(tmpClassAttr(i))
Next
processFile = True
End Function
'------------------------------------------------------------
'Function: parseAtt(num, attrData, ByVal m As MineKnow)
'require:
' >@num -> current attribute counter
' >@attrData -> current attribute declaration
'Raises: error if reading non numeric data/attribute
'Return: boolean parseAtt TRUE/FALSE, TRUE if parse successfully or otherwise
'Effect: parsing file content to:
' > attributes
'------------------------------------------------------------
Private Function parseAtt(num, attrData)
Dim temp, i, j, strAtt, temp2, pos, atVal
ReDim Preserve attArray(2, num)
'possible type of declarations
'@attribute outlook {sunny, rainy, overcast}
'@attribute outlook {sunny,rainy,overcast}
'attribute pos = 12
'get the attribute name first get the pos of "{"
pos = InStr(1, attrData, "{", 1)
If (pos = 0) Then
error = "---->Nominal attribute only." & vbCrLf & "---->" & attrData
parseAtt = False
Exit Function
Else
strAtt = Trim(Mid(attrData, 12, pos - 12))
atVal = Mid(attrData, pos + 1, Len(attrData) - (pos + 1))
atVal = Replace(atVal, "'", "")
atVal = Replace(atVal, "''", "")
atVal = Replace(atVal, "}", "")
atVal = Replace(atVal, " ", "")
temp = Split(atVal, ",")
attArray(0, num) = strAtt
attArray(1, num) = temp
parseAtt = True
End If
End Function