arrays - .NET stream writer Variable format -
i'm trying write csv file variable output format.
the code is
fs.writeline(string.format(format, data(0), data(1), data(2), data(3), data(4), data(5) ) )
this works, if i'm trying pass same argument
data(0), data(1), data(2), data(3), data(4), data(5)
in string
str = "data(3) , data(2) , data(1) , data(0)" fs.writeline(string.format(format, str))
i error
index (zero based) must greater or equal 0 , less size of argument list.
what doing wrong?
this literal string:
str = "data(3) , data(2) , data(1) , data(0)"
what want string array this:
str = {data(3), data(2), data(1), data(0)}
note: have change declaration of str
being string being string array from:
dim str string
to
dim str string()
however
if have bunch of variables write out csv can more this:
using sr new streamwriter(filename) dim sb new stringbuilder each value in data sb.append(value & ",") next sr.writeline(sb.tostring.trimend(","c)) end using
Comments
Post a Comment