|
-
Jan 19th, 2000, 08:30 AM
#1
Thread Starter
Addicted Member
Please help me with this problem.
Some How I can't get this code to work.
It works great when I only use 1 Array Element Group but when I use 2 I get a runtime error 340 and a message that says: "Control Array Element '1' Doesent exist"
Code:
Public iNumOfOperator As Integer
Public iNumOfOwner As Integer
Private Sub Form_Load()
iNumOfOwner = 1
iNumOfOperator = 9
Dim sFile As String
Dim iTextbox As Integer
On Error GoTo NoFile
With cdbLoadSave
.DialogTitle = "Open User Configuration.."
.Filter = "Usr File (.Usr)|*.usr"
.CancelError = True
.ShowOpen
sFile = .FileName
End With
On Error GoTo 0
Open sFile For Input As 1
While Not EOF(1)
Line Input #1, sFile
If Left(sFile, 6) = "[Owner" Then
iTextbox = Val(Trim(Mid(sFile, 7, InStr(sFile, "]") - 1)))
txtOwner(iTextbox) = ""
Else
txtOwner(iTextbox) = txtOwner(iTextbox) & sFile & vbCrLf
End If
If Left(sFile, 9) = "[Operator" Then
iTextbox = Val(Trim(Mid(sFile, 10, InStr(sFile, "]") - 1)))
txtOperator(iTextbox) = ""
Else
txtOperator(iTextbox) = txtOperator(iTextbox) & sFile & vbCrLf
End If
Wend
Close 1
NoFile:
End Sub
If you can Help me that would be great.
Thanks anyway.
-Lumin
-
Jan 19th, 2000, 09:26 PM
#2
Frenzied Member
Which line causes the Error?
------------------
Mark Sreeves
Analyst Programmer
[email protected]
A BMW Group Company
-
Jan 20th, 2000, 01:10 AM
#3
Thread Starter
Addicted Member
The line I got an error on is:
Code:
txtOwner(iTextbox) = txtOwner(iTextbox) & sFile & vbCrLf
Hope this helps.
-Lumin
-
Jan 20th, 2000, 04:42 AM
#4
Go to your form and look at the properties for txtOwner. The code assumes that there is a txtOwner control with an Index property of 1. Is there?
------------------
Marty
Can you buy an entire chess set in a pawn shop?
-
Jan 20th, 2000, 05:38 AM
#5
Thread Starter
Addicted Member
I have only 1 txtOwner Texbox since the program is made to only server 1 owner.
I can't see if this should do any difference.
I just added 3 more textboxses to see if it made any diferences, the only thing that showed up was that Array element '4' was missing. So im back where I started.
but if you got any sugjestions please post em. 
-Lumin
-
Jan 20th, 2000, 05:43 AM
#6
The Code is Reading in an Index Number from the Opened File, Check the File to See what the highest Index Number is, that is how many Textboxes you Require.
As you are using a Textbox Control Array, you need to make sure you have enough Controls in the Array to Match the Index you retrieve from the file each time.
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
Jan 21st, 2000, 07:31 AM
#7
Thread Starter
Addicted Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|