Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems using a Public Array 1

Status
Not open for further replies.

mtroche

Civil/Environmental
Jun 4, 2001
39
I want to store some data to a Public Array but the following Error Message appears:

"Complie error

Constants, fixed-length strings, arrays, user-defined types
and Declare statements not allowed as Public memebers of object modules."

I am using a UserForm to get the information at first time and, then, call the information from the array as needed. What is the problem with my code? :-( Below you can see the code related with my problem.



Public dd1
Public Data(1 To 100, 1 To 100, 1 To 14)
____________________________________________________________

Private Sub Calculate_Click()
Static d1
If SmallerPole = "" Or HigherPole = "" Or _
Spacing = "" Or ElevationS = "" Or ElevationH = "" Then
MsgBox "All Fields in 'Poles in Span' Must Be _
Filled.", vbInformation, "Check"
GoTo 10
ElseIf IsNumeric(HigherPole) = False Or _
IsNumeric(SmallerPole) = False Then
MsgBox "The IDs for Pole #1 and #2 must be Numbers.", _
vbInformation, "Check"
GoTo 10
ElseIf SmallerPole > HigherPole Or _
SmallerPole = HigherPole Or _
SmallerPole < 0 Or HigherPole < 0 Then
MsgBox &quot;Verify that the ID Number for Pole #1 is _
smaller than the ID Number for Pole #2 and _
that both of them are positive.&quot;, _
vbInformation, &quot;Check&quot;
GoTo 10
ElseIf IsNumeric(Spacing) = False Or _
IsNumeric(ElevationS) = False Or _
IsNumeric(ElevationH) = False Then
MsgBox &quot;Input Numeric Data for the Spacing, _
Elevation #1 and Elevation #2.&quot;, _
vbInformation, &quot;Check&quot;
GoTo 10
ElseIf Clearance = &quot;&quot; And HT = &quot;&quot; Then
MsgBox &quot;Fill the Clearance or the Horizontal _
Tension to Start the Calculations.&quot;, _
vbInformation, &quot;Check&quot;
GoTo 10
ElseIf Clearance <> &quot;&quot; And HT <> &quot;&quot; Then
MsgBox &quot;Just Fill the Clearance or the Horizontal _
Tension. Do Not Fill Both of Them.&quot;, _
vbInformation, &quot;Check&quot;
GoTo 10
ElseIf IsNumeric(Clearance) = False And HT = &quot;&quot; Then
MsgBox &quot;Input Numeric Data for the Clearance.&quot;, vbInformation, &quot;Check&quot;
GoTo 10
ElseIf IsNumeric(HT) = False And Clearance = &quot;&quot; Then
MsgBox &quot;Input Numeric Data for the Horizontal _
Tension.&quot;, vbInformation, &quot;Check&quot;
GoTo 10
End If

d1 = d1 + 1
Data(d1, 1, 1) = SmallerPole
Data(d1, 1, 2) = HigherPole
Data(d1, 1, 3) = Spacing
Data(d1, 1, 4) = ElevationS
Data(d1, 1, 5) = ElevationH
Data(d1, 1, 6) = Clearance
Data(d1, 1, 7) = HT
Data(d1, 2, 1) = CodeWord1
Data(d1, 2, 2) = CodeWord2
Data(d1, 2, 3) = CodeWord3
Data(d1, 2, 4) = CodeWord4
Data(d1, 2, 5) = CodeWord5
Data(d1, 2, 6) = CodeWord6
Data(d1, 2, 7) = CodeWord7
Data(d1, 2, 8) = CodeWord8
Data(d1, 2, 9) = CodeWord9
Data(d1, 2, 10) = CodeWor10
Data(d1, 2, 11) = CodeWord11
Data(d1, 2, 12) = CodeWord12
Data(d1, 2, 13) = CodeWord13
Data(d1, 2, 14) = CodeWord14
Data(d1, 3, 1) = Quantity1
Data(d1, 3, 2) = Quantity2
Data(d1, 3, 3) = Quantity3
Data(d1, 3, 4) = Quantity4
Data(d1, 3, 5) = Quantity5
Data(d1, 3, 6) = Quantity6
Data(d1, 3, 7) = Quantity7
Data(d1, 3, 8) = Quantity8
Data(d1, 3, 9) = Quantity9
Data(d1, 3, 10) = Quantity10
Data(d1, 3, 11) = Quantity11
Data(d1, 3, 12) = Quantity12
Data(d1, 3, 13) = Quantity13
Data(d1, 3, 14) = Quantity14
Data(d1, 4, 1) = Delta1
Data(d1, 4, 2) = Delta2
Data(d1, 4, 3) = Delta3
Data(d1, 4, 4) = Delta4
Data(d1, 4, 5) = Delta5
Data(d1, 4, 6) = Delta6
Data(d1, 4, 7) = Delta7
Data(d1, 4, 8) = Delta8
Data(d1, 4, 9) = Delta9
Data(d1, 4, 10) = Delta10
Data(d1, 4, 11) = Delta11
Data(d1, 4, 12) = Delta12
Data(d1, 4, 13) = Delta13
Data(d1, 4, 14) = Delta14
dd1 = d1
10
End Sub
____________________________________________________________

Private Sub Spacing_Change()
Dim n As Byte
For n = 1 To dd1
If Data(n, 1, 1) = SmallerPole And _
Data(n, 1, 2) = HigherPole Then
Spacing.Value = Data(n, 1, 3)
End Sub
End If
Next n
End Sub

 
Replies continue below

Recommended for you

Put the line
Public Data(1 To 100, 1 To 100, 1 To 14)
in a module, not a form
 
FrancisL,

When I use the Form, I have a Button &quot;OK&quot; so when I press it the information in the ComboBoxes are stored in an array. Now, when I'm wrighting the data in the form the program check if the data for POle1 and Pole 2 exist in the same array and use the data in the array for those poles. If the data for POLe1 and Pole 2 doesn't exists in the same array the program accept the new data and store it in the next array.

Now, if I put the &quot;line&quot; in the OK Botton, it will be ok; I mean, the program will work and it will not be erased any information from the array?

Thanks for your answer.. I'll be waiting for this one!!
 
Did you try what I suggested?
&quot;Constants, fixed-length strings, arrays, user-defined types
and Declare statements not allowed as Public memebers of object modules.&quot; means just that

Alternatively just change
Public Data(1 To 100, 1 To 100, 1 To 14)
to
Dim Data(1 To 100, 1 To 100, 1 To 14)

Francis
 
Thank you, FrancisL. Your information worked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor