NSA
sudo apt-get thefuckout.tar.gz
- Dec 9, 2011
- 715
- 86
Hello all,
I am using VB to create an array, but when I run the program I get the following error:
Error1'ReDim' statements can no longer be used to declare array variables.C:\Users\Josh\AppData\Local\Temporary Projects\array\Form1.vb2472array
Here is my code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strSongNames() As String 'Array of song names
Dim blDimensioned As Boolean 'Is the array dimensioned?
Dim strText As String 'To temporarily hold names
Dim lngPosition As Long 'Counting
'The array has not yet been dimensioned:
blDimensioned = False
Do
'Ask for a song name
strText = InputBox("Enter a song name:")
If strText <> "" Then
'Has the array been dimensioned?
If blDimensioned = True Then
'Yes, so extend the array one element large than its current upper bound.
'Without the "Preserve" keyword below, the previous elements in our array would be erased with the resizing
ReDim Preserve strSongNames(0 To UBound(strSongNames) + 1) As String
Else
'No, so dimension it and flag it as dimensioned.
ReDim strSongNames(0 To 0)
blDimensioned = True
End If
'Add the song name to the last element in the array.
strSongNames(UBound(strSongNames)) = strText
End If
Loop Until strText = ""
'Display entered song names:
For lngPosition = LBound(strSongNames) To UBound(strSongNames)
MsgBox(strSongNames(lngPosition))
Next lngPosition
'Erase array
Erase strSongNames
End Sub
I am using VB to create an array, but when I run the program I get the following error:
Error1'ReDim' statements can no longer be used to declare array variables.C:\Users\Josh\AppData\Local\Temporary Projects\array\Form1.vb2472array
Here is my code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strSongNames() As String 'Array of song names
Dim blDimensioned As Boolean 'Is the array dimensioned?
Dim strText As String 'To temporarily hold names
Dim lngPosition As Long 'Counting
'The array has not yet been dimensioned:
blDimensioned = False
Do
'Ask for a song name
strText = InputBox("Enter a song name:")
If strText <> "" Then
'Has the array been dimensioned?
If blDimensioned = True Then
'Yes, so extend the array one element large than its current upper bound.
'Without the "Preserve" keyword below, the previous elements in our array would be erased with the resizing
ReDim Preserve strSongNames(0 To UBound(strSongNames) + 1) As String
Else
'No, so dimension it and flag it as dimensioned.
ReDim strSongNames(0 To 0)
blDimensioned = True
End If
'Add the song name to the last element in the array.
strSongNames(UBound(strSongNames)) = strText
End If
Loop Until strText = ""
'Display entered song names:
For lngPosition = LBound(strSongNames) To UBound(strSongNames)
MsgBox(strSongNames(lngPosition))
Next lngPosition
'Erase array
Erase strSongNames
End Sub