SetFieldWidths problem

Hi
I need some help with the SetFieldWidths in  Microsoft.VisualBasic.FileIO.FieldType.FixedWidth

Can I pass a variable to the SetFieldWidths insted of hardcode it

Now i have  Reader.SetFieldWidths(5, 10, 11, -1)

but I want to make a function for this so I need to set the parameters dynamic.

is this possible?

LVL 1
AWestEngAsked:
Who is Participating?
 
SanclerCommented:
       Dim arr As Integer = {1, 3, 9, -1}
        Reader.SetFieldWidths(arr)

Or

        Dim arr(3) As Integer
        arr(0) = 1
        arr(1) = 3
        arr(2) = 9
        arr(3) = -1
        Reader.SetFieldWidths(arr)

Or similar

Roger
0
 
chinu1310Commented:
Simply create variable and pass them as parameter.
0
 
AWestEngAuthor Commented:
I need one varible, and how should I pass i it to  Reader.SetFieldWidths(...


0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
chinu1310Commented:
Reader.SetFieldWidths(5, 10, 11, -1)

In this what parameter you want dynamic ?
create variable say int a

If its user input let it be from some textbox.

And than pass like Reader.SetFieldWidths(a, 10, 11, -1)
0
 
AWestEngAuthor Commented:
that dosent work.. i nedd to pas

one time 10 one time 100 one time 1 and so on
0
 
AWestEngAuthor Commented:
I need to pass a array
0
 
chinu1310Commented:
Ohh ok.

than you can declare an array with prefix values.
At first time take first value from array.
this way

Reader.SetFieldWidths(a[i], 10, 11, -1)
Immediately after that increase the value of i.
(Initially i should be 0).

next time whey you use this  

Reader.SetFieldWidths(a[i]...

It would be a[2]


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.