|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VB AssistanceI am working on an assignment and need some assistance if anyone could help:
Need to use a for next statement and give a value to five elements usin a one dimensional integer array value So far I have Sub Main() Dim integer As Integer Dim Value as Integer Value = 8 For Integer = 1 to 5 I don't know how to continue this..any suggestions?? Thanks You should never name something using a reserved word, like "integer" (VB is
not a case-sensitive language so "integer" and "Integer" are the same thing). You were also unclear as to whether you already have 5 values and just need to assign them to members of an array or whether you are using values from the array to assign to 5 "elements" (whatever that means) somewhere else. Here's my best guess at what you are trying to do: Sub Main() Dim values As Integer(4) 'Notice the trailing parenthesis ()? This means values should be an Integer array values(0) = 27 'Made up value values(1) = 32 'Made up value values(2) = 16 'Made up value values(3) = 7 'Made up value values(4) = -12 'Made up value 'This assumes you already have some "element" (as you call it) and since I don't know what you mean 'by "element", I can't know what property to set on it. But, this should give you the idea For i As Integer = 0 to values.length - 1 element(i) = values(i) Next End Sub Show quote "kirad832" <kirad***@discussions.microsoft.com> wrote in message news:5B05700D-C082-49EF-88B3-49DF293F2A41@microsoft.com... > I am working on an assignment and need some assistance if anyone could > help: > > Need to use a for next statement and give a value to five elements usin a > one dimensional integer array value > > So far I have > > Sub Main() > Dim integer As Integer > Dim Value as Integer > Value = 8 > > For Integer = 1 to 5 > > > I don't know how to continue this..any suggestions?? > > Thanks > |
|||||||||||||||||||||||