VB School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB Expert!

Join 307,087 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,252 people online right now. Registration is fast and FREE... Join Now!




Control array not being recognized

 

Control array not being recognized, When I try to call a control array index, it says Function or Sub not

nickel1976

6 Aug, 2009 - 09:11 AM
Post #1

New D.I.C Head
*

Joined: 4 Aug, 2009
Posts: 2

I set up the following control array using this code:

CODE
Dim index

Private Sub Option1_Click()
    List1.Clear
    For index = 0 To 9
        List1.AddItem SampleRacks(index, 0)
    Next
    Text1.Text = ""
    NumCol.Text = ""
    NumRow.Text = ""
    XPos1.Text = ""
    YPos1.Text = ""
    XPos2.Text = ""
    YPos2.Text = ""
End Sub

Private Sub Option2_Click()
    List1.Clear
    For index = 0 To 9
        List1.AddItem OutputRacks(index, 0)
    Next
    Text1.Text = ""
    NumCol.Text = ""
    NumRow.Text = ""
    XPos1.Text = ""
    YPos1.Text = ""
    XPos2.Text = ""
    YPos2.Text = ""
End Sub

Private Sub List1_Click()
    If Option1.Value = True Then
        Text1.Text = SampleRacks(List1.ListIndex, 0)
        NumCol.Text = SampleRacks(List1.ListIndex, 1)
        NumRow.Text = SampleRacks(List1.ListIndex, 2)
        XPos1.Text = SampleRacks(List1.ListIndex, 3)
        YPos1.Text = SampleRacks(List1.ListIndex, 4)
        XPos2.Text = SampleRacks(List1.ListIndex, 5)
        YPos2.Text = SampleRacks(List1.ListIndex, 6)
    End If
    If Option2.Value = True Then
        Text1.Text = OutputRacks(List1.ListIndex, 0)
        NumCol.Text = OutputRacks(List1.ListIndex, 1)
        NumRow.Text = OutputRacks(List1.ListIndex, 2)
        XPos1.Text = OutputRacks(List1.ListIndex, 3)
        YPos1.Text = OutputRacks(List1.ListIndex, 4)
        XPos2.Text = OutputRacks(List1.ListIndex, 5)
        YPos2.Text = OutputRacks(List1.ListIndex, 6)
    End If
End Sub

Private Sub Command1_Click()
    If Option1.Value = True Then
        SampleRacks(List1.ListIndex, 0) = Text1.Text
        SampleRacks(List1.ListIndex, 1) = NumCol.Text
        SampleRacks(List1.ListIndex, 2) = NumRow.Text
        SampleRacks(List1.ListIndex, 3) = XPos1.Text
        SampleRacks(List1.ListIndex, 4) = YPos1.Text
        SampleRacks(List1.ListIndex, 5) = XPos2.Text
        SampleRacks(List1.ListIndex, 6) = YPos2.Text
        List1.Clear
        For index = 0 To 9
            List1.AddItem SampleRacks(index, 0)
        Next
    Else
        OutputRacks(List1.ListIndex, 0) = Text1.Text
        OutputRacks(List1.ListIndex, 1) = NumCol.Text
        OutputRacks(List1.ListIndex, 2) = NumRow.Text
        OutputRacks(List1.ListIndex, 3) = XPos1.Text
        OutputRacks(List1.ListIndex, 4) = YPos1.Text
        OutputRacks(List1.ListIndex, 5) = XPos2.Text
        OutputRacks(List1.ListIndex, 6) = YPos2.Text
        List1.Clear
        For index = 0 To 9
            List1.AddItem OutputRacks(index, 0)
        Next
    End If
End Sub


I'm referring to it using this code:

Private Sub Form_Load()
' reading the configuration file
'CONTENTS; data for the last procedure which was setup
'PortNumber
'ProcedureName
'SampleRackIndex
'OutputRack1Index
'OutputRack2Index

Open "config.spc" For Random As #1
Get #1, , filebuffer
PortNumber = filebuffer
Get #1, , filebuffer
ProcedureName = filebuffer
If ProcedureName = "" Then ProcedureName = "Default.zyp"
Text18.Text = ProcedureName
Get #1, , filebuffer
SampleRackIndex = filebuffer
Get #1, , filebuffer
OutputRack1Index = filebuffer
Get #1, , filebuffer
OutputRack2Index = filebuffer
Close 1

LoadProcedure (ProcedureName)

Dim index
For index = 0 To 9
Combo1.AddItem SampleRacks(index, 0)
Next index
Combo1.ListIndex = SampleRackIndex

For index = 0 To 9
Combo2.AddItem OutputRacks(index, 0)
Next index
Combo2.ListIndex = OutputRackIndex

For index = 0 To 9
Combo3.AddItem OutputRacks(index, 0)
Next index
Combo3.ListIndex = OutputRackIndex

End Sub[code]

I get this error when I try to run it:

Compile error: Sub or Function not defined

The red word is highlighted. What am I forgetting to do?

User is offlineProfile CardPM
+Quote Post


thava

RE: Control Array Not Being Recognized

7 Aug, 2009 - 05:55 PM
Post #2

D.I.C Addict
Group Icon

Joined: 17 Apr, 2007
Posts: 905



Thanked: 52 times
Dream Kudos: 75
My Contributions
what is
SampleRacks?

is it an array then declare it
i think there after you will not get any error
User is offlineProfile CardPM
+Quote Post

vb5prgrmr

RE: Control Array Not Being Recognized

7 Aug, 2009 - 07:03 PM
Post #3

D.I.C Regular
***

Joined: 21 Mar, 2009
Posts: 486



Thanked: 30 times
My Contributions
To begin with, control arrays do not have multiple dimensions (index, 0) so if it is an array or a multimentional array, where is it declared and what are its dimensions?



Good Luck


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 10:45AM

Live VB Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month