User talk:Glennh
Feedback
You wanted some feedback. Here ya go. :-)
First, thanks for contributing to Rosetta code. Here are some tips to help make the process easier for readers, and for people like me who spend most of their time touching up formatting:
You submitted:
VBScript
Language Version: N/A
Simple Example
' Define our Array Dim myArray (5) ' ' Use a For Next loop to set the array data. For i = 0 To 4 myArray(i) = i Next ' ' Use a For Next loop and MsgBox to display the array data. MsgBox("Print array values") For i = 0 To 4 msgbox("myArray element " & i & " = " & myArray(i)) Next
Example where we don't know the required array size at the start and where we need to increase the array size as we go
' Define an array - but we don't know how big yet. Dim myArray2 () ' ' OK, now we know how big an array we need. ReDim myArray2(3) ' ' Load the array For i = 0 To 2 myArray2(i) = i Next ' 'Print the array MsgBox("We've set the new array size and set the data") For i = 0 To 2 MsgBox "myArray2 element " & i & " = " & myArray2(i) Next ' ' Now we need to make the array bigger. ' Note the Preserve keyword so that the existing data in the array is not lost when we resize it. ReDim Preserve myArray2(5) ' ' Load the array For i = 3 To 4 myArray2(i) = i Next ' 'Print the array MsgBox ("We've increased the array size and loaded more data") For i = 0 To 4 MsgBox "myArray2 element " & i & " = " & myArray2(i) Next
This is how I would have formatted it:
VBScript
Simple Example
Define our Array
Dim myArray (5)
Use a For Next loop to set the array data.
For i = 0 To 4 myArray(i) = i Next
Use a For Next loop and MsgBox to display the array data.
MsgBox("Print array values") For i = 0 To 4 msgbox("myArray element " & i & " = " & myArray(i)) Next
Example where we don't know the required array size at the start and where we need to increase the array size as we go
Define an array - but we don't know how big yet. Dim myArray2 ()
OK, now we know how big an array we need.
ReDim myArray2(3)
Load the array
For i = 0 To 2 myArray2(i) = i Next
Print the array
MsgBox("We've set the new array size and set the data") For i = 0 To 2 MsgBox "myArray2 element " & i & " = " & myArray2(i) Next
Now we need to make the array bigger. Note the Preserve keyword so that the existing data in the array is not lost when we resize it.
ReDim Preserve myArray2(5)
Load the array
For i = 3 To 4 myArray2(i) = i Next
Print the array
MsgBox ("We've increased the array size and loaded more data") For i = 0 To 4 MsgBox "myArray2 element " & i & " = " & myArray2(i) Next
...
This way, we take advantage of the wiki formating for the comments. Commentary is more easily read when it's easily distinguishable from the code itself. I also removed the "Language Version" line. If a programming example doesn't have require special conditions, it's not necessary to say so.
All in all, though, great job! Thanks for contributing. --Short Circuit 22:03, 4 February 2007 (EST)
Thanks for the feedback
Hi Short Circuit - thanks for the feedback re my VBScript entry - I do like your formatting and I'll use that myself in future.
thanks
GlennH