将函数拆分为数组。类型不匹配错误#13

时间:2016-02-11 18:19:57

标签: arrays ms-access split access-vba type-mismatch

我有一个字符串,其中多个电子邮件地址以分号分隔,并希望将它们拆分为单独的值。

Dim RecipientArray() As Variant 'I've also tried as string
Debug.Print txtRecipients.Value
RecipientArray = Split(txtRecipients.Value, ";") 'error happens here
For i = 0 To UBound(RecipientArray)
    Debug.Print RecipientArray(i)
Next

1 个答案:

答案 0 :(得分:4)

使RecipientArray成为普通的Variant而不是Variant数组。

'Dim RecipientArray() As Variant 'I've also tried as string
Dim RecipientArray As Variant