|
-
Nov 3rd, 2000, 06:39 PM
#1
Thread Starter
Member
I've made a simple activeX control (just a textbox in an array that acts like a datarepeater by multipling itself down the form as your use my '.addnew' method) and i used the VB ActiveX ctl Wizard to add all the backcolor and font properties and all that jazz to it. I've compiled it and it works fine, but when i put it in one of my projects, it breaks the 'trim' function (actually it doesnt recognize it, it thinks its an array because its in the format 'trim(blah)' and pops up and error saying 'array expected').
what could cause this? references in my control project clashing with refs in my main project? im at a loss...
-
Nov 3rd, 2000, 06:52 PM
#2
Well ...
Can you post the code in which you are getting this error? Also the name you have used for the activeX control etc.?
-
Nov 3rd, 2000, 06:54 PM
#3
Frenzied Member
Post the line of code that's breaking...
You are most likely trying to trim the text in a control array but are only refering to the control name and not the index of the control.
Example:
Code:
' Pretend you want to set the caption of a label equal to the trimmed
' value of a text box that is part of a control array.
' This will fail because the index for Text1 is missing:
Label1.Caption = Trim$(Text1.Text)
' This will work just fine:
Label1.Caption = Trim$(Text1(0).Text)
Hope that helps. If it didn't, post the code around (and including) the line that's breaking so we can understand better what's going on. I guarantee you that you DIDN'T break the Trim function 
-
Nov 4th, 2000, 12:43 PM
#4
Thread Starter
Member
The error pops up in my INI file parsing class, not when im referencing the control (which BTW, its name is 'txtRepeat').
i can take my control out, it works, put it back in, trim breaks. ive taken it out and put it back in several times and the same thing happens, so its safe to say, somehow the control is screwing things up.
heres the code that it errors on:
Code:
Public Function GetValue(ByVal szKey As String) As String
'Reads through the ini file, parsing each line into a key/value pair.
'When it finds the key that matches the input parameter, it returns
'the corresponding value. If it does not find a key that matches the
'input parameter it returns an empty string.
On Error GoTo GetValue_Err
'Start the Function by setting it to its failure value.
GetValue = ""
Dim sziniline As String
Dim szLineKey As String
Dim szValue As String
Dim nEqualsPosition As Integer
Dim nLineLength As Integer
'open file that was passed to Setini
Open m_sziniFile For Input As 1
'loop until function hits end of file
Do While Not EOF(1)
'read in one line from the file and store it in sziniline
Line Input #1, sziniline
'make sure the line is not empty
If sziniline <> "" Then
'find the "=" in the ini line
nEqualsPosition = InStr(1, sziniline, "=")
'pull the key out of the ini line
szLineKey = Trim(Left(sziniline, nEqualsPosition - 1))
'compare key to passed string
If LCase(szLineKey) = LCase(szKey) Then
'get length of the ini line
nLineLength = Len(sziniline)
'trim the key and "=" from the ini line
szValue = Trim(Right(sziniline, nLineLength - (nEqualsPosition + 1)))
'return ini line sans the key and the "="
GetValue = szValue
End If
End If
Loop
'close the file
Close 1
GetValue_Exit:
Exit Function
GetValue_Err:
MsgBox "An error has occurred. Please contact your System Administrator" & vbCrLf & vbCrLf & "Error: " & Err.Source & vbCrLf & Err.Description, vbOKOnly, "Error"
Resume GetValue_Exit
End Function
it breaks on:
Code:
'pull the key out of the ini line
szLineKey = Trim(Left(sziniline, nEqualsPosition - 1))
the word 'Left' is highlighted and the err msgbox says 'Expected Array'
im at a loss
-
Nov 6th, 2000, 01:43 PM
#5
Frenzied Member
Step through your code
Set a break point on the line that's generating your error and see what the values are for:
sziniline and szEqualsPosition
When you know what these are, I suspect you may find your problem. If not, post the values of these variables (when the error occurs) here and we may be able to give you some help.
P.S. You should probably be checking that szEqualsPosition is not zero before you continue on with the processing.
-
Nov 7th, 2000, 01:21 PM
#6
Thread Starter
Member
its not a value problem, and i was wrong before when i said it was trim that was broken, its Left() thats asking for an array.
i know its not a value problem (and i cant step thru it) because it doesnt break on that line, it breaks at the begining of the function with the function declaration highlighed (yellow) and the word 'Left' is highlighed (like when you drag your cursor over something to highlight it).
if its possible can i email my control to someone and have them add it to a project and use the Left() function in it to see what the problem is?
-
Nov 7th, 2000, 02:46 PM
#7
Frenzied Member
I'll take a look at it if you want...
Please zip all the files together before mailing (if you can...it saves download time) and mail it to:
[email protected]
-
Nov 7th, 2000, 03:52 PM
#8
Thread Starter
Member
Its in route, thanks for the help!
-
Nov 7th, 2000, 04:15 PM
#9
Frenzied Member
Try this...
Hope this works for you...
I took a look at your code and noticed that you had the following Public Enum:
Code:
Public Enum AlignmentType
Left = 0
Right = 1
Center = 2
End Enum
Somehow I think this is causing problems...VB is looking at "Right" and not seeing it as the function (at least not after compilig) but as your AlignmentType Enumeration value. Don't ask me why this is happening (if, indeed, this is the problem).
My suggestion is you change your Enum to something like this:
Code:
' Try using names that aren't already used by VB, like this:
Public Enum AlignmentType
LeftAlign = 0
RightAlign = 1
CenterAlign = 2
End Enum
' Or this:
Public Enum AlignmentType
atLeft = 0
atRight = 1
atCenter = 2
End Enum
I think if you make this change, your problem should go away.
Let me know how it goes!
-
Nov 7th, 2000, 04:37 PM
#10
Thread Starter
Member
DOH!?!
thanks, i feel really dumb about now.
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
|