aProducts(lRow) = Array("Id Product", "Value A", "Value B")
'To copy value A
aProducts(lRow) = Array(.Cells(aPos(1)).Value2, .Cells(aPos(2)).Value2, Empty)
'To copy value B
aProducts(lRow) = Array(.Cells(aPos(1)).Value2, Empty, .Cells(aPos(3)).Value2)
大家好,
我在循环中使用这段代码来复制一些值及其ID,但无论如何,现在我想了解此代码中“Empty”的用法,以便增加更多价值。
我试过了:
aProducts(lRow) = Array("Id Product", "Value A", "Value B", "Value C")
'To copy value A
aProducts(lRow) = Array(.Cells(aPos(1)).Value2, .Cells(aPos(2)).Value2, Empty)
'To copy value B
aProducts(lRow) = Array(.Cells(aPos(1)).Value2, Empty, .Cells(aPos(3)).Value2)
'To copy value C
aProducts(lRow) = Array(.Cells(aPos(1)).Value2, Empty, Empty, .Cells(aPos(4)).Value2)
“Execusiion error 9”
提前致谢,对不起我的近似英语:/
编辑1
您可以在此处获取该文件:https://drive.google.com/file/d/0B5DpGwPWsIfbWWlJRDAzZldYek0/view?usp=sharing
编辑2
感谢大家,我发现我忘了删除
ReDim Preserve aProducts(lRow)
答案 0 :(得分:3)
写下以下内容:
Option Explicit
Sub TestMe()
Dim arr_var As Variant
arr_var = Array(Empty, Empty, 5)
Stop
End Sub
答案 1 :(得分:1)
这对你有用吗?您复制时似乎忘了更新最后一个。
.Cells(aPos(4)).Value2)
我还认为您希望更新4
以获得3
而不是form Files
sentence Input_dir ./
positive Start 0.21
positive End 0.45
endform
createDirectory("output")
list = Create Strings as file list: "list", input_dir$ + "*.wav"
numberOfFiles = Get number of strings
for ifile to numberOfFiles
selectObject: list
fileName$ = Get string: ifile
sound = Read from file: input_dir$ + fileName$
sound_name$ = selected$("Sound")
# Find zero crossings
start = Get nearest zero crossing: 1, start
end = Get nearest zero crossing: 1, end
sound_end = Get total duration
# Cut the selected part out, shortening the sound
# by extracting the part before and after and concatenating
before = Extract part: 0, start, "rectangular", 1, "no"
selectObject: sound
after = Extract part: end, sound_end, "rectangular", 1, "no"
selectObject: before, after
new = Concatenate
removeObject: before, after
## Or, if you want to set the selected part to zero
## (since we already have the zero crossings)
# new = Set part to zero: start, end, "at exactly these times"
## Or, if what you want is to get only the selected part
## and not the original sound
# new = Extract part: start, end, "rectangular", 1, "no"
# Either way, the new, modified sound is selected
# and its ID is stored in `new`
Save as WAV file: "./output/" + fileName$
# I prefer a less shotgunny way to remove unwanted objects
removeObject: sound, new
endfor
removeObject: list
。