Solved

# Hard Code Values to an Array

Posted on 2009-03-29
533 Views
Hi EE.

I am not great with regular arrays, but I am attempting to create an array that will hold values a.b.c.d.e.f etc. depending on how many columns I have.
I retrieve the number of columns and then assign it to the array, but how do I assign the a,b,c etc. to the array  and how do I pick the values out?
Thanks
``````Dim cc As Integer = Me.fpGrdGeneric.ActiveSheet.ColumnCount - 1
Dim arr(cc) As Array = a,b,c,??
``````
0
Question by:Sheritlw

LVL 65

Expert Comment

ID: 24016730
maybe some tips as described here may help? http://www.vb-helper.com/howto_net_declare_arrays.html
0

LVL 6

Accepted Solution

HarryNS earned 250 total points
ID: 24016752
Dim Test() As Integer
Test = New Integer() {1, 3, 5, 7, 9}

Dim Test1() As String
Test1 = New String() {"a", "b", "c", "d"}
0

LVL 47

Assisted Solution

Wayne Taylor (webtubbs) earned 250 total points
ID: 24016781
For a start, you need to declare it as String, as the way you have it is declaring an array of Arrays.

Then you need to fill it like this....

Dim arr(cc) As String
For c As Integer = 0 To cc - 1
arr(c) = Chr(65 + c).ToString
Next

Wayne
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

#### 810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.