Results 1 to 10 of 10

Thread: activeX control breaks things....

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2000
    Location
    New Orleans, LA
    Posts
    37
    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...

  2. #2
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    Can you post the code in which you are getting this error? Also the name you have used for the activeX control etc.?

    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  3. #3
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Wink 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
    ~seaweed

  4. #4

    Thread Starter
    Member
    Join Date
    Sep 2000
    Location
    New Orleans, LA
    Posts
    37
    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




  5. #5
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Exclamation 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.
    ~seaweed

  6. #6

    Thread Starter
    Member
    Join Date
    Sep 2000
    Location
    New Orleans, LA
    Posts
    37
    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?

  7. #7
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    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]
    ~seaweed

  8. #8

    Thread Starter
    Member
    Join Date
    Sep 2000
    Location
    New Orleans, LA
    Posts
    37
    Its in route, thanks for the help!

  9. #9
    Frenzied Member
    Join Date
    Jan 2000
    Location
    Bellevue, WA, USA
    Posts
    1,357

    Question 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!
    ~seaweed

  10. #10

    Thread Starter
    Member
    Join Date
    Sep 2000
    Location
    New Orleans, LA
    Posts
    37
    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
  •  



Click Here to Expand Forum to Full Width