-
This is my first shot at a simple array and the use of an InputBox. VB doesn't like the code in the Inputbox line and I get the error - expected As. I've tried all ways to correct this line... (code below)what have I done wrong?
GRAHAM
Private Sub Form_Load()
Dim I As Integer
Dim Name(3) As String
For I = 1 To 3
Name(1) = InputBox("Enter names", "Array Demo", "insert here")
Next I
'just print names on form
For I = 1 To 3
Print "Name is"; Name(I)
Next I
End Sub
-
The problem is Name is a reserved VB command For Renaming Files/Folders, ie.
Code:
Name "C:\This.txt" As "C:\That.txt"
Try this:
Code:
Private Sub Form_Load()
Dim I As Integer
Dim sName(3) As String
For I = 1 To 3
sName(I) = InputBox("Enter names", "Array Demo", "insert here")
Next I
Show
'just print names on form
For I = 1 To 3
Print "Name is "; sName(I)
Next I
End Sub
-
Thanks Aaron
Doh! I should have spotted that
GRAHAM